Page 1 of 1

How to sort numbers ? [Solved]

Posted: Tue Jun 30, 2015 1:03 pm
by atout66
Hi to all,

I try to sort numbers which are in item 2 of a line.
Here is my code:

Code: Select all

set the itemDelimiter to "|"     -- a line of laListePartielle  = <abaque|12456|abak|FALSE|2> for example
     sort laListePartielle ascending by item 2 of each
In fact, it doesn't sort anything :?

Have you an idea why ?
Thanks in advance, Jean-Paul.

Re: How to sort numbers ?

Posted: Tue Jun 30, 2015 1:07 pm
by Klaus
Bonjour Jean-Paul,

just wrong/incomplete syntax (dictionary, hint, hint)! 8)
...
sort LINES OF laListePartielle ascending NUMERIC by item 2 of each
...
will do the trick!


Best

Klaus

Re: How to sort numbers ?

Posted: Tue Jun 30, 2015 1:19 pm
by atout66
Oups, I apologize, but as you probably noticed already, there is no such example in the dictionary...
I tried also:
sort laListePartielle ascending by numeric by item 2 of each but got an error syntax of course !

At least I hope this tread will help beginners like me if they search the forum with <sort numbers> keyword.

Merci pour ton aide Klaus :wink:

Re: How to sort numbers ? [Solved]

Posted: Tue Jun 30, 2015 1:21 pm
by Klaus
From the dictionary:
...
sort lines of tData descending numeric by item 1 of each
...
But that was under -> sort container :D


Best

Klaus

Re: How to sort numbers ? [Solved]

Posted: Tue Jun 30, 2015 4:19 pm
by jacque
Sorting by lines is the default if no chunk is specified, so the original should have worked. Something odd is going on. What version of LiveCode are you using?

Re: How to sort numbers ? [Solved]

Posted: Tue Jun 30, 2015 6:36 pm
by dunbarx
The:

"by numeric" will throw an error, but the first code fragment did not contain that. That first post works fine.

Craig