Sorting search results - solution needed
Bob Sneidar
bobsneidar at iotecdigital.com
Tue Oct 23 17:14:34 EDT 2018
Okay I misunderstood. So were it not for the multiple periods in a single value, you could have sorted numeric by word 1 of each, then resorted alphabetically by word 2 of each. The wrench in the works is the double periods. For this you can write a function that builds a string for a value passed and use that in your by each clause. I would extract the integer portion of the value, pad it with a maximum number of trailing zeros, say 10, then append the rest.
So for example 187 becomes 1870000000. 187a becomes 1870000000a. 187.01 mecomes 1870000000.01. 187 (a) becomes 1870000000 (a). And finally, 10187 becomes 1018700000.
This of course cannot be a numeric sort. I would create a loop and start with 1 digit, then see if the value div the value = the value (in a try catch loop). Once you get an error or false, break out the integer portion, pad it with the appropriate number of trailing zeros, then append the rest.
Bob S
> 187
> 187a
> 187 (a)
> 187 (a)(1)
> 187 (b)
> 187 (b)(1)
> 187c
> 187.c
> 187.01
> 187.02
> 187.1
> 187.1.1
> 187.1.2
> 187.3
> 187.22
> 187.33
> 187.234
> 187.456
> 10187
> 18700
Bob S
More information about the use-livecode
mailing list