Sort so that "Hello" is always before "hello"

Dr. Hawkins dochawk at gmail.com
Thu May 18 17:50:22 EDT 2017


On Thu, May 18, 2017 at 2:20 PM, Bob Sneidar via use-livecode <
use-livecode at lists.runrev.com> wrote:

> What you are wanting to do is a recursive function that sorts within each
> word. If the first character is all you care about, it would be easy
> enought to code, but if *every* character comes into play, the problem
> becomes grossly complex. This isn't a sort problem. It's a filing order
> problem


so

sort the lines of mycontainer by mysort of each


where mysort is a function previously defined.

Or, perhaps more creatively

repeat for each line theLin in theData

put theLin into arry[mysort(theLin)

end repeat

put the keys of arry into srtVals

sort lines of srtVals

repeat for each line theLin in srtVals

put arry[theLin] & cr after newData

end repeat


where mysort() simply rearranges the characters into order AaBb etc.  (so
"A" maps to "a", "a" maps to "b", and so forth, leaving the rest of the
ascii intact.  Or perhaps it could remap the symbols & numbers to
preference, too.   There are something like 95! possible mappings . . .

-- 
Dr. Richard E. Hawkins, Esq.
(702) 508-8462



More information about the Use-livecode mailing list