Bizarre Number Sort of Files Mac

Bob Sneidar bobsneidar at iotecdigital.com
Fri Mar 9 14:18:49 EST 2018


Hmmm... I ran into this a few days ago. If you sort numeric, and any of the values are not numeric, the sort fails silently. I would have expected it to sort with the affinity for numeric, but that apparently is not how the sort command works. If you were to simply sort without the numeric arguement, it would work, since your filenames are already padded with zeros. If this needs to work with *any* file list, I think you may be in trouble. 

One option would be to iterate in a repeat loop through each line, then iterate through each character, adding the current character to a value then checking if the value is a number. When it's not, put char 1 to -2 of the value into item 1 of a new list, the actual filename into item 2 of the new list, sort lines of <list> numeric ascending by item 1 of each, then iterate through the lies again, putting item 2 of each line in a new list. 

You could create a function that does this. 

Bob S


> On Mar 9, 2018, at 10:46 , PEL via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> When you add text to a number, it ceases to be a number.
> 
> If you had a space between 01-11-04-09-_2018 and the rest of the line you might be able to
> 
> sort lines of field “TheFiles” dateTime ascending by word one of each
> 
> 
> Paul Looney



More information about the use-livecode mailing list