sort container

Geoff Canyon gcanyon at inspiredlogic.com
Sun Jan 20 02:51:00 EST 2002


At 9:59 PM +0100 1/19/02, yves COPPE wrote:
>in the doc, I read :
>The sort container command is a stable sort. This means that if the sortKey for two items or lines is the same, sorting does not change their order, so you can do two successive sorts to create subcategories within the major sort categories.
>
>
>I can't apply it to the following problem :
>
>Let's suppose a tabstop fld
>
>the first column contains dates
>the second text
>
>I'd like to sort the fld so that
>it's sorted by date (first column)
>and afterwards sorted by text (alphabetically)
>
>in this case the sortkey changes first it's item 1 of fld "xxx" and then it's item 2 of fld "xxx"

If I understand what you want correctly, then something like this should do the trick:

set the itemDelimiter to tab
sort fld "someField" by item 2 of each
sort fld "someField" dateTime by item 1 of each

The stable sort aspect allows this to work: the first sort orders the lines of the field by the text. The second sort order the lines of the field by the date, and where the date is the same, leaves the order unchanged, which means those lines will still be sorted by the text.

regards,

Geoff



More information about the use-livecode mailing list