in reply to Re^2: Complex conditional sort
in thread Complex conditional sort
Fair enough ikegami.
I like using the !!$test construct to force a boolean to 1 or (''/0). However, if that isn't clear enough, I'd probably choose using the >0 test.
sort {$products{Cat}{Pro}{$b}{Qua}>0 <=> $products{Cat}{Pro}{$a}{Q +ua}>0 || $a <=> $b}
I suppose it still requires some level of understanding of the possible return values of conditionals, but that's one of the most important things to be familiar with when dealing with sorting in my opinion. Especially the <=> and cmp operators.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Complex conditional sort
by ikegami (Patriarch) on Mar 09, 2011 at 07:15 UTC | |
by wind (Priest) on Mar 09, 2011 at 19:27 UTC | |
by ikegami (Patriarch) on Mar 09, 2011 at 20:42 UTC | |
by wind (Priest) on Mar 09, 2011 at 21:00 UTC |