in reply to Re^2: Notation of sort function
in thread Notation of sort function
I dont think [one of the operands isn't $a or $b at all] can be logic.
Here is one example. In the case where you just want all values which meet some criterion moved to the beginning or end of the list then you can do something like this:
#!/usr/bin/env perl use strict; use warnings; my @words = qw/The omega quick brown omega fox jumps over the omega la +zy dog/; my @sorted = sort { $a eq 'omega' ? 1 : -1 } @words; print "@sorted\n";
This moves all the 'omega' entries to the end of the array but the other entries are not predictably sorted. Not something you are going to need every day but useful to have in the toolbox for those rare occasions which call for it.
🦛
|
---|