Confirm sort container order...

Craig Newman craig at starfirelighting.com
Tue Apr 5 13:52:05 EDT 2022


Paul.

I see you have come to the dark side. Welcome.

“Sort", and its newly reborn compound variant, works fine as "sort it ascending numeric by word 1 of each && word 2 of each && word 3 of each”

Since “lines” are the default, all one needs, and I mentioned this on the forum, is to determine the line with the greatest number of words, and build the string accordingly. This takes another couple of lines of code, but no more than having that very same number laid out in a series of single line sorts, still having to be determined by the maximum number of words or items. whatever.

Craig

> On Apr 5, 2022, at 12:08 PM, Paul Dupuis via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> On 4/5/2022 10:58 AM, Craig Newman via use-livecode wrote:
>> The discussion may seem academic to some, and perhaps pointless to others. But I like this sort of nonsense, and actually believe it is rather more than just that. In fact, it speaks to the internal working of the “sort” command itself, which seems counterintuitive at least, and a mystery at best.
>> 
>> 
> 
> I certainly agree a nice enhancement to sort would be something like
> 
> sort lines of <var> by item 3 of each then [by] item 2 of each then [by] item 1 of each
> 
> to replicate exactly (below) but in a single, easier to read, line
> 
> sort lines of <var> by item 3 of each
> sort lines of <var> by item 2 of each
> sort lines of <var> by item 1 of each
> 
> a reduction in code and a more intuitive way of stating a multi-level sort with the addition of a "then", "then by", or some sort of delimiter keyword
> 
> Still that assumes you want to do an ascending text sort for all 3 levels, since ascending text is the default and the syntax is
> 
> sort lines <var> ascending text by item 3 of each
> 
> If you want different sorts for each key
> 
> sort lines of <var> ascending text by item 3 of each
> sort lines of <var> descending numeric by item 2 of each
> sort lines of <var> ascending international by item 1 of each
> 
> might still be easier that any new syntax that reads something like:
> 
> sort lines of <var> by item 3 of each ascending text then by item 2 of each descending numeric then by item 1 of each ascending international
> 
> Although the single line is slightly shorter code and still relatively easy to read. Still, I have NO idea how difficult it would be to add the syntax to the LC engine. If not too difficult to implement, it could be a handy enhancement to LC's sort.
> 
> 
> _______________________________________________
> 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