Basic sorting problem
Eric Chatonet
eric.chatonet at sosmartsoftware.com
Wed May 7 07:35:04 EDT 2008
Bonjour David,
First, here, it works for me (Mac OS - last Rev 2.9): sort
objectNames by the number of words of each
Second if you want to use a function, it should be something like:
on test_WordSort
put object_GetNames() into objectNames --
sort objectNames descending by NumOfWords() --
------
repeat for each line someLine in objectNames
put the number of words of someLine & tab & someLine & CR after
someResult
end repeat
put someResult
end test_WordSort
-------------------------------
function NumOfWords
return the number of words of each line
end NumOfWords
But it does the same and does not seem useful :-)
Le 7 mai 08 à 12:47, David Bovill a écrit :
> If I am not doing something wrong I think this is a bug - if so it
> would be
> good to confirm on other platforms as it is pretty basic. I am
> trying to
> sort lines by the number of words in each line. I can do it with
> the nuber
> of chars but not the number of words or tokens. Here are the test
> scripts:
>
> on test_CharSort
>> put object_GetNames() into objectNames
>>
>> -- this is sorting fine!
>> sort objectNames by the number of chars of each
>>
>> repeat for each line someLine in objectNames
>> put the number of chars of someLine & tab & someLine & CR
>> after
>> someResult
>> end repeat
>> put someResult
>> end test_CharSort
>>
>> on test_WordSort
>> put object_GetNames() into objectNames
>>
>> -- why is this not sorting?
>> sort objectNames by the number of words of each
>>
>> repeat for each line someLine in objectNames
>> put the number of words of someLine & tab & someLine & CR
>> after
>> someResult
>> end repeat
>> put someResult
>> end test_WordSort
>>
>> on test_TokenSort
>> put object_GetNames() into objectNames
>>
>> -- why is this not sorting?
>> sort objectNames by the number of tokens of each
>>
>> repeat for each line someLine in objectNames
>> put the number of tokens of someLine & tab & someLine & CR
>> after
>> someResult
>> end repeat
>> put someResult
>> end test_TokenSort
>>
>> function object_GetNames
>> repeat with controlNum = 1 to the number of controls
>> put the long name of control controlNum into longName
>> put longName & CR after objectNames
>> end repeat
>> delete char -1 of objectNames
>> return objectNames
>> end object_GetNames
>
>
> A fix now is to sort using a function - now if only I could
> remember the
> syntax for that....
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list