Confirm sort container order...

Paul Dupuis paul at researchware.com
Tue Apr 5 12:08:42 EDT 2022


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.




More information about the use-livecode mailing list