Alphaphi: I dont see redundancy, I think the syntax is flexible to permit also different use cases.
> There are cases where one might want to apply different conditions on the operands..
mmh.. yes this can also be true but I suppose just as a trigger inside comparison: which apple is heavier but golden one count more
use strict; use warnings; use Data::Dump; my %apples = ( one => { weight => 10, golden=> 0}, two => { weight => 20, golden=> 0}, three => { weight => 5 , golden=> 1}, ); my @sorted = sort{ ( $apples{$b}->{golden} ? $apples{$b}->{weight} * 10 : $apples{$b}->{weight} ) <=> ( $apples{$a}->{golden} ? $apples{$a}->{weight} * 10 : $apples{$a}->{weight} ) }keys %apples; dd @sorted; __END__ ("three", "two", "one")
> ..or where one of the operands isn't $a or $b at all
I dont think this can be logic. Also in sort of misunderstanding of sort you can find that sort is optimized, so not every pair is checked so if you will sort apple against pear I wonder which use case can be.
Courious to know otherwise :)
L*
In reply to Re^2: Notation of sort function
by Discipulus
in thread Notation of sort function
by Alphaphi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |