As is usually the case with Damian's writings, the juiciest bits (imho) are usually a bit of the way down the page. In this case, the best part is at the bottom. sort will (apparently) now handle both the Schwartzian Transform and Orcish Manuver naturally. In fact, all sorts will have the Orcish built in. (Will there be a way to turn this off? Will we care?)
The Schwartzian is taken care of by the fact that you won't be limited to just comparators anymore. You'll be able to tell sort how to find the sorting key for a given element and sort will be smart enough to know if it should sort with <=> or cmp.
In the middle, there's a really really grossly oversized sort used as an example. Let's just say I'm glad both that Perl6 will simplify things immensely and that Damian made Uri's thoughts more Perlish. As an comparison, I had started to try and build that sort in Perl5. And gave up about halfway down. (Oh - make sure you read the sorting keys/compartors from left to right, not right to left like in Perl5.)
In summary, I think that most of us will be specifying keys for our sorts instead of comparators, but I really like the idea of "dropping down" into comparator mode, if needed.
------
We are the carpenters and bricklayers of the Information Age.
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl6 sorting
by kvale (Monsignor) on Mar 03, 2004 at 16:26 UTC | |
by TimToady (Parson) on Mar 03, 2004 at 16:59 UTC | |
by matija (Priest) on Mar 06, 2004 at 12:24 UTC |