Page 1 of 1

Different Sort of Sort

Posted: Sun May 22, 2016 7:34 pm
by RossG
I have lines in a field:

1 BHO
4 RLO
6 BHE

etc.

Is there a way to sort them on item 2?

Re: Different Sort of Sort

Posted: Sun May 22, 2016 9:33 pm
by dunbarx
Hi.

Yes.

But I do not see the items. If you had:

cat,dog
deer,ticks
night,day

And did this:

Code: Select all

sort thatList by item 2 of each
Would give you:

night,day
cat,dog
deer,ticks

Read up on the sort command in the dictionary.

Craig Newman

Re: Different Sort of Sort

Posted: Mon May 23, 2016 11:55 am
by Klaus
If it HAS to be ITEMS:
...
set itemdel to SPACE
sort lines of fld X by item 2 of each
...
If NOT:
...
sort lines of fld X by WORD 2 of each
...
8)

Re: Different Sort of Sort

Posted: Thu May 26, 2016 4:58 pm
by RossG
Klaus

I was thinking of a function from my FoxPro days:

char to ASCII

ASCII to char.

The only place I see ASCII mentioned in the
Dictionary is in reference to sorting (I think).

Re: Different Sort of Sort

Posted: Thu May 26, 2016 5:08 pm
by richmond62
Well I made a stack as per your recipe and put THIS in my button [I called my listField "ff"]:

on mouseUp
sort fld "ff" by char 2 of each
end mouseUp

and it sorted the items by the second letter.

The only potential snag is that it put those 3 items
in lines 4,5 and 6 of the field.

Of course IFF you are using Unicode characters things will get a bit more awkward.

Re: Different Sort of Sort

Posted: Wed Jun 08, 2016 4:14 pm
by MaxV

Code: Select all

sort field 1 by word 2 of each
It works, moreover you can do more complex sorting, but always start from right ( http://livecode.wikia.com/wiki/Sorting )