Multiple sorting helper

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple sorting helper

Esteban A. Maringolo
Hi,

I have a collection of objects and I want to sort its contents by more
than one attribute (including nil values), and I thought somebody
might have already done this.

Something like:

sorter := MultipleSortCriteria new
               add: #lastName;
               add: [:each | each personalInfo age ] ascending: false.
aCollection asSortedCollection: sorter.

Is there a package with utility classes for this?

Thank you!

Esteban A. Maringolo

pwl
Reply | Threaded
Open this post in threaded view
|

Re: Multiple sorting helper

pwl
I wrote a SortCriteria and SortCriteriaColumn objects, affectionately known as Sort Critter way back in the 90's and published it as open source for Squeak and other smalltalks back in 1999. The code should work in Pharo with almost no changes. http://lists.squeakfoundation.org/pipermail/squeak-dev/1999-July/017163.html It has it's own web page here that includes the downloads: http://www.smalltalk.org/components/SortCriteria.html SortCritter is now under any of the BSD, MIT, Apache, GPLv2 licenses, you choose.