Sorting Advice

dunbarx at aol.com dunbarx at aol.com
Sun Jan 15 12:53:44 EST 2012


There is a more compact way. Read the notes in the dictionary about "sort". You may concatenate the sortKeys. This will at least reduce the command to a single line. Not sure if it is faster, though.


Craig Newman



-----Original Message-----
From: Pete <pete at mollysrevenge.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Tue, Jan 10, 2012 9:33 am
Subject: Re: Sorting Advice


Hi Marty,
I'm not too familiar with the sort command but it sounds like you could use
the each keyword and write a custom function to return the concatenated
values of items 1 and 2 (zero padding item 2 so you could sort works on
text), thus sorting in 1 pass.   I have no idea whether it would be any
quicker than two passes.
Pete

On Tue, Jan 10, 2012 at 9:10 AM, Marty Knapp <martyknapp at comcast.net> wrote:

> OK, so I'm good. Just though I might be missing something. Thanks Stephen.
>
> Marty
>
>> I think one has to make multiple passes - the doc say for "sort
>> container":
>>
>> *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.*
>> *
>> *
>> * Tip: To create a custom sort order, use the eachkeyword to pass each
>> line
>> or item to a custom function. The valuereturned by the function is used as
>> the sort key for that line or item. Note that it is not currently possible
>> to debug custom sort functions, and doing so could make the IDE unstable.
>> It is recommended to use logging messages instead.*
>>
>>
>> On 9 January 2012 20:33, Marty Knapp<martyknapp at comcast.net>  wrote:
>>
>>  I have a list that I'm currently sorting as follows:
>>>
>>> --item 2 may be a word or a number
>>> --item 1 is a date
>>>
>>> sort the lines of myList by item 2 of each --sort any words
>>> alphabetically
>>> sort the lines of myList numeric by item 2 of each --sort the numbers
>>> (any
>>> words go to the top of the list in the order provided in the first step)
>>> sort the lines of myList dateTime by item 1 of each --sort by date
>>>
>>> While this gives me what I need, is there a faster way to do this?
>>>
>>> Thanks,
>>> Marty
>>>
>>
> ______________________________**_________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 



More information about the use-livecode mailing list