The first sort is straightforward, and turns "1,2,4,5,6,8,9" into "9,8,6,5,4,2,1"
The second sort splits that into two groups. The first group is the entries that fail the test, the second is the entries that pass the test. Since the test is ">=", 5 passes the test and goes in the second group. That makes the result "4,2,1,9,8,6,5" I think it could also be written as sort items of pList by not (each < V) But I'm guessing that would be a bit slower (maybe not) It would probably be clearer to do this: sort items of pList numeric sort items of pList by each < V return item -1 of pList But that adds the burden of getting item -1, i.e. parsing the whole list a final time. If the engine were optimized for negative items it wouldn't matter much, but since it's not, I inverted the rest of the statements to be able to get item 1 at the end. On Mon, Oct 12, 2015 at 11:06 PM, J. Landman Gay <jac...@hyperactivesw.com> wrote: > On 10/12/2015 6:24 PM, Geoff Canyon wrote: > >> function greatestLessThan pList,V >> sort items of pList descending numeric >> sort items of pList by each >= V >> return item 1 of pList >> end greatestLessThan >> > > Clever. How come it works when V is in the list, when you're asking for > ">=" ? Seems like V should be toward the front of the second sort. > > I used this: > > put greatestLessthan("1,2,4,5,6,8,9",5) > > The 5 was at the end of the second sorted list, even though it's equal to > V. > > -- > Jacqueline Landman Gay | jac...@hyperactivesw.com > HyperActive Software | http://www.hyperactivesw.com > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode