sort container parameters

Craig Newman craig at starfirelighting.com
Wed Mar 3 13:23:47 EST 2021


I thought I was pretty clever at using “do”, often going down several levels,  evaluating the whole way before trying to execute a single  “do” statement.

Neither of the last lines seem to work:

on mouseup

put "A,C,T,B" into toSort

put "ascending" into sortDir

get "sort items of" && quote & toSort & quote && sortDir

breakpoint

--do it

--do "sort" && toSort && sortDir

do "sort" && quote & toSort & quote && sortDir

end mouseup


I feel there must be a way…

Craig


> On Mar 2, 2021, at 7:36 PM, Alex Tweedly via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> The number of lines being sorted makes o difference.
> 
> The number of distinct sorts will - but at a single 'do' for each of "several hundreds", you'll not even notice except (maybe) if you are benchmarking it (around 5ms per 1000 'do's on an elderly MacBook Pro).
> 
> Alex.
> 
> On 02/03/2021 22:52, Paul Dupuis via use-livecode wrote:
>> Okay. Thank you Ralph.
>> 
>> I was reluctant to use "do" for performance reasons. The sort could be sorting a large number of lines - as many as several hundred sorts of a thousand to ten thousand lines.
>> 
>> I could of course do timing trials, but does anyone from the mothership (or anyone period) know if using "do" with a container sort causes any appreciable performance hit? All the data is in a variable (vs fields).
>> 
>> 
>> On 3/2/2021 5:19 PM, Ralph DiMola via use-livecode wrote:
>>> I found that you must us a "Do"(thank heaven for "Do"s) if you want to make variable any LC token that colorizes like "stack", "the", "field", "button", "put" or "ascending".
>>> 
>>> I don't think "Do" is a kludge is this case.
>>> 
>>> Ralph DiMola
>>> IT Director
>>> Evergreen Information Services
>>> rdimola at evergreeninfo.net
>>> 
>>> -----Original Message-----
>>> From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf Of Paul Dupuis via use-livecode
>>> Sent: Tuesday, March 02, 2021 4:56 PM
>>> To: use-livecode at lists.runrev.com
>>> Cc: Paul Dupuis
>>> Subject: sort container parameters
>>> 
>>> I just discovered much to my dismay that you can not execute the following:
>>> 
>>> put "ascending" into tDirection
>>> soft lines of tContainer tDirection international
>>> 
>>> apparently neither the sort direction (ascending|descending) nor the sort type (international|text|datetime|numeric|binary) can be variable!
>>> 
>>> That means if you want to parameterize a sort direction, you have to do something like:
>>> 
>>> if tDirection is "ascending" then
>>>     sort lines of tContainer ascending international else
>>>     sort lines of tCOntainer descending international end if
>>> 
>>> I see this a a bug or perhaps a failure to fully robust impliment the sort container command? Does any one else see this as a bug?
>>> 
>>> I suppose I could work around it with a "do" but that seems like a cludge
>>> 
>>> do ("sort line of tContainer" && tDirection && tSortType)
>>> 
>>> Thoughts? Comments? Opinions? Am I expecting too much of LiveCode to have sort direction and type actual parameters?
>>> 
>>> 
>>> _______________________________________________
>>> 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
>>> 
>>> 
>>> _______________________________________________
>>> 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
>> 
>> 
>> _______________________________________________
>> 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
> 
> _______________________________________________
> 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