Craig,
It's because when you try to sort something, it's got to be a variable that's
being sorted. So all of the examples you used put "toSort" into the statement
to be "done" coming out compiled as:
sort items of "A,C,T,B" ascending
... which won't work. You need to execute:
do "sort items of toSort" && sortDir
which compiles to:
sort items of toSort ascending
... and that works.
:)
Ken Ray
Sons of Thunder Software, Inc.
Email: [email protected]
Website: https://www.sonsothunder.com
> On Mar 3, 2021, at 12:23 PM, Craig Newman via use-livecode
> <[email protected]> wrote:
>
> 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
>> <[email protected]> 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
>>>> [email protected]
>>>>
>>>> -----Original Message-----
>>>> From: use-livecode [mailto:[email protected]] On
>>>> Behalf Of Paul Dupuis via use-livecode
>>>> Sent: Tuesday, March 02, 2021 4:56 PM
>>>> To: [email protected]
>>>> 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
>>>> [email protected]
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>>
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [email protected]
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [email protected]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> [email protected]
>> Please visit this url to subscribe, unsubscribe and manage your subscription
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [email protected]
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode