sort ... by ... of each is far more powerful than I knew

Mark Schonewille m.schonewille at economy-x-talk.com
Mon Sep 16 08:10:48 EDT 2013


Hi Geoff,

You forget one, although you included length() and abs():

sort lines of myVar by anyFunction(each)

You can also combine multiple sorts in a sequence and you can nest sorts 
in custom functions.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com

Buy my new book "Programming LiveCode for the Real Beginner" 
http://qery.us/3fi

Fill out this survey please
http://livecodebeginner.economy-x-talk.com/survey/

On 9/16/2013 10:11, Geoff Canyon wrote:
> I just blew my own mind. Maybe I'm slow, but I had no idea any of this
> would work. I started with this data in a field.
>
> test 1,this,5,apple
> test 2,the,-2,pear
> test 3,a,2,grape
> test 4,oh,0,strawberry
>
> Then I put a copy of that data in x and sorted it with various commands as
> follows:
>
>     sort lines of x numeric ascending by item 3 of each
>
> test 2,the,-2,pear
> test 4,oh,0,strawberry
> test 3,a,2,grape
> test 1,this,5,apple
>
>
>     sort lines of x numeric ascending by item 3 of each * word 2 of item 1
> of each
>
> test 2,the,-2,pear
> test 4,oh,0,strawberry
> test 1,this,5,apple
> test 3,a,2,grape
>
>
>     sort lines of x numeric descending by abs(item 3 of each * word 2 of
> item 1 of each)
>
> test 3,a,2,grape
> test 1,this,5,apple
> test 2,the,-2,pear
> test 4,oh,0,strawberry
>
>
>     sort lines of x by item 3 of each > word 2 of item 1 of each
>
> test 2,the,-2,pear
> test 3,a,2,grape
> test 4,oh,0,strawberry
> test 1,this,5,apple
>
>
>     sort lines of x by (item 3 of each > word 2 of item 1 of each) && item 4
> of each
>
> test 3,a,2,grape
> test 2,the,-2,pear
> test 4,oh,0,strawberry
> test 1,this,5,apple
>
>
>     sort lines of x numeric descending by length(item 4 of each) - (item 3
> of each)
>
> test 4,oh,0,strawberry
> test 2,the,-2,pear
> test 3,a,2,grape
> test 1,this,5,apple




More information about the Use-livecode mailing list