Sorting search results - solution needed

hh hh at hyperhh.de
Wed Oct 24 03:33:42 EDT 2018


As Craig said, your rules are not consistent to standards:

You sort *after* the first period numeric with the exception
that leading zeros are "valid".
That's why the replace in the following function is needed.

This now yields exactly your custom sort order:

function gregSort s
  set itemdel to "."
  sort s numeric by offset("a",each)
  sort s numeric by offset("b",each)
  sort s numeric by offset("c",each)
  replace ".0" with ".0." in s --> begin make leading zeros valid
  sort s numeric by item 2 to 3 of each
  replace ".0." with ".0" in s --> end make leading zeros valid
  sort s numeric by item 1 of each
  return s
end gregSort





More information about the use-livecode mailing list