[Newbies] How to sort a SortedCollection like you can sort a
table in Excel?
Bert Freudenberg
bert at freudenbergs.de
Mon Apr 12 14:36:41 UTC 2010
On 12.04.2010, at 16:13, Paul DeBruicker wrote:
>
> 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:
>
Sure. Basically your sort block would look like
a height > b height or: [
a height = b height and: [
a width > b width or: [
a width = b width and: [
a depth > b depth]]]]
- Bert -
More information about the Beginners
mailing list