"Kinky" sort...
Mark Smith
mark at maseurope.net
Mon Sep 19 08:58:08 EDT 2005
Something like this, in transcript?
repeat for each line L in vData
-- split the data into an array using the group as keys (no group
lines go into groupZ)
if item 3 of L is not empty then
put L & cr after groupArray[item 3 of L]
else
put L & cr after groupArray[groupZ]
end if
end repeat
put the keys of groupArray into kList
sort lines of kList
repeat for each line L in kList
sort lines of groupArray[L] numeric by item 4 of each
put groupArray[L] & cr after theSortedList
end repeat
filter theSortedList without empty -- strip any empty lines from
trailing crs
gives you:
1,text 1,group1,20050104
2,text 2,group1,20050104
8,text 8,group1,20050104
5,text 5,group2,20050104
3,text 3,group2,20051004
10,text 10,group3,20050104
4,text 4,group3,20051004
7,text 7,,20050104
6,text 6,,20050204
9,text 9,,20050204
(I inserted commas as the itemDelimiter into the original data)
Is this the order you wantd?
Mark
On 19 Sep 2005, at 09:45, Ton Kuypers wrote:
> Hi gang,
>
> I am out of inspiration, somebody please help me...
>
> I've got a listbox containing a list of data:
> ID Description Group Date
> 1 text 1 group1 20050104
> 2 text 2 group1 20050104
> 3 text 3 group2 20051004
> 4 text 4 group3 20051004
> 5 text 5 group2 20050104
> 6 text 6 20050204
> 7 text 7 20050104
> 8 text 8 group1 20050104
> 9 text 9 20050204
> 10 text 10 group3 20050104
>
> The date column is in fact the result of the seconds-function.
> The data is the result of a SQL query to mySQL
>
> I need to sort the list on date, without splitting the groups and
> thats where I'm out of luck:
> When I use
> Sort vData with item 4 of each
> Sort vData with item 3 of each
> the groups are divided, when I use
> Sort vData with item 3 of each
> Sort vData with item 4 of each
> the result first shows the lines without any groups, followed by
> the lines containing groups.
>
> How do I display these lines in the correct order without splitting
> the groups?
> The dates within a group could differ (but not likely) but in that
> case the first first date should be the line to sort.
>
> Anybody any suggestions for using a kinky SQL statement or how to
> setup a sort in RR?
>
> Regards & many thanks in advance,
>
> Ton Kuypers
> _______________________________________________
> 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