Sort
Posted: Tue May 23, 2017 2:40 am
I have a field as in the attached.
I want to sort on item 3.
Can't figure out a way to do it.
Help appreciated
I want to sort on item 3.
Can't figure out a way to do it.
Help appreciated
Questions and answers about the LiveCode platform.
https://www.forums.livecode.com/
Code: Select all
on mouseUp
put fld 1 into cntnr
replace tab with ",=," in cntnr
-- 19-2,=,Z,=,04,05,06,08,09,21,27,31,=,202
repeat with j=12 down to 5 --> 8 comma-items
sort cntnr numeric by item j of each
end repeat
replace ",=," with tab in cntnr
put cntnr into fld 1
end mouseUp
Hallo Hermann,[-hh] wrote:Is the itemdelimiter tab and you wish to sort lexicographically (co-sorted) numeric by the 8 comma-items of tab-item 3?
Code: Select all
on mouseUp
put fld 1 into T
set the itemdelimiter to tab
sort lines of T numeric by replaceText( item 3 of each, comma, empty)
put T
end mouseUp
[-hh] wrote:Brilliant .
True.(Although the numbers must have, as it is here the case, the same length.
That is, leading zeros where necessary. And no decimals and no negative numbers are allowed).
Thanks Hermann for your ideas...[-hh] wrote:Hi Thierry,
May I propose you as speaker?
"Basic and advanced examples of using regex within LiveCode script"
Would be very interesting.
Code: Select all
sort fld 1 numeric by item 3 of each
Code: Select all
on mouseUp
set the itemdel to tab
sort lines of fld 1 by item 3 of each
end mouseUp