in reply to Notation of sort function
It's a good question. There are cases where one might want to apply different conditions on the operands or where one of the operands isn't $a or $b at all. These cases are rare but they do crop up from time to time.
I have had a trawl through some code of mine and haven't found one yet. Closest I have is this:
@abc = sort { length ($b) <=> length ($a) || $a cmp $b } @abc;
Even through here we are treating $a and $b in the same way, I don't know how you would express this without the flexibility that the current syntax gives. It would not be as succinct, that's for sure.
🦛
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Notation of sort function
by Discipulus (Canon) on Oct 27, 2023 at 10:43 UTC | |
by hippo (Archbishop) on Oct 28, 2023 at 12:43 UTC | |
by Alphaphi (Acolyte) on Oct 27, 2023 at 14:05 UTC | |
by tybalt89 (Monsignor) on Oct 27, 2023 at 18:56 UTC | |
by kcott (Archbishop) on Oct 27, 2023 at 16:03 UTC | |
by ikegami (Patriarch) on Oct 27, 2023 at 19:11 UTC |