SORT by length

Jerry Jensen jerry at jhjensen.com
Mon Aug 7 18:51:10 EDT 2017


So what did it do? With all those asterisks I can’t run it without retyping the whole thing.

> On Aug 7, 2017, at 3:42 PM, Richmond Mathewson via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> That scr*wed up badly.
> 
> I found this: http://forums.livecode.com/viewtopic.php?f=9&t=10505#p48529
> 
> and modified it:
> 
> *on**mouseUp*
> 
> **
> 
> ***put**empty **into**rSortByLength*
> 
> **
> 
> ***put**fld "CL" **into**tText*
> 
> **
> 
> ***repeat****for**each word tLine in tText*
> 
> **
> 
> ***put**tLine&"," &**the****length****of**tLine&**return****after**rSortByLength*
> 
> **
> 
> ***end****repeat*
> 
> **
> 
> ***delete**char -1 **of**rSortByLength*
> 
> **
> 
> ***sort**lines **of**rSortByLength descending numeric by item 2 **of**each*
> 
> **
> 
> ***put**empty **into**fld "CL"*
> 
> **
> 
> ***put**rSortByLength **into**fld "CL"*
> 
> **
> 
> ***--*
> 
> **
> 
> ***put**1 **into**KOUNT*
> 
> **
> 
> ***repeat**until line KOUNT **of**fld "CL" is empty*
> 
> **
> 
> ***delete****the**last char **of**line KOUNT **of**fld "CL"*
> 
> **
> 
> ***delete****the**last char **of**line KOUNT **of**fld "CL"*
> 
> **
> 
> ***add**1 **to**KOUNT*
> 
> **
> 
> ***end****repeat*
> 
> **
> 
> *end**mouseUp*
> 
> 
> Richmond.
> 
> 
> On 8/8/17 1:29 am, Jerry Jensen via use-livecode wrote:
>> From the dictionary entry for “sort”: If you don't specify a direction, the sort is ascending. One of the following items: • ascending -sorts in ascending order • descending -sorts in descending order
>>> On Aug 7, 2017, at 3:23 PM, Richmond Mathewson via use-livecode <use-livecode at lists.runrev.com> wrote: I have a listField containing a number of words which I want to order so the longest comes first . . . doing this: sort lines of fld "myGuff" by length(each) sorts the words, but the shortest one comes first…
>> _______________________________________________ use-livecode mailing list use-livecode at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list