Did you know that Squeak offers declarative sorting? This allows you to avoid le...

@squeak@fosstodon.org

Did you know that Squeak offers declarative sorting?

This allows you to avoid lengthy manual comparisons:

animals sorted: [:a :b |
a age > b age or: [
a age = b age and: [
a name <= b name]]].

Instead, you can declare and chain multiple sort functions:

animals sorted: #age descending , #name ascending.

Since Squeak 6.1, boolean predicates are supported as well:

animals sorted: #hasTail sortedFirst , #canSwim sortedLast , #name ascending.

#Programming #SoftwareEngineering