[Newbies] How to sort a SortedCollection like you can sort a table
in Excel?
Paul DeBruicker
pdebruic at gmail.com
Mon Apr 12 14:13:24 UTC 2010
Hi -
If I had a SortedCollection of rectangular solid objects (that just have
the ivars height, width, depth), how could I sort it by height, then
width, then depth?
So three object:
A) h: 10, w: 5, d: 3
B) h: 60, w: 2, d: 14
C) h: 10, w: 3, d: 27
And then after sorting they'd be in this order:
B) h: 60, w: 2, d: 14
A) h: 10, w: 5, d: 3
C) h: 10, w: 3, d: 27
First sorted by height, then by width, then by depth.
Is there a way to do that using just a #sortBlock:
My only other approach would be to make a Set of the heights, sort that,
then #select: a collection for each height, sort that by weight, then
for each height make a Set of weights etc...
Thanks
Paul
More information about the Beginners
mailing list