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
About This Hashtag
#hastail
1 posts
Last used 5d
#hastail
1 posts· Last used 5d
You've seen all posts