Page 1 of 1

Sort by item 1 and then item 2

Posted: Mon Oct 03, 2016 8:17 pm
by LouisThompson
Hi all,

I'm sure this is fairly simple but I can't get my head round it. I have a field which contains...

1 1
4 5
1 3
2 1
4 2
4 4
2 3
1 2
4 1
2 2
4 3
2 4
3 1
3 2

It like to sort it first by item 1 (Itemdelimiter is tab) and then item 2 so the field reads...

1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 1
3 2
4 1
4 2
4 3
4 4
4 5

Any help would be gratefully appreciated.

Thanks

Louis

Re: Sort by item 1 and then item 2

Posted: Mon Oct 03, 2016 8:58 pm
by LiveCode_Panos
Hi Louis,

try this:

Code: Select all

on mouseUp
   set the itemdel to tab
   sort lines of fld 1 by item 2  of each
   sort lines of fld 1 by item 1  of each
end mouseUp
Best,
Panos
--

Re: Sort by item 1 and then item 2

Posted: Mon Oct 03, 2016 9:05 pm
by LouisThompson
Many thanks! Was sorting by item 1 first THEN item 2.
This works great!

Re: Sort by item 1 and then item 2

Posted: Tue Oct 04, 2016 2:11 am
by dunbarx
You can do this in one line:

Sort this by sortKey1 & sortKey2 & ...

Craig Newman