in reply to Sort undef
I think you can define your own sorting sub cmp_undef.
Something like
sub cmp_undef { my ( $a, $b ) = @_; return $a cmp $b if defined $a and defined $b; return $b cmp $a; # invert order otherwise } @$ResultsFinal = sort \&cmp_undef(...,...), @$ResultsFinal;
Untested!
Update:
wait this might go wrong if cmp_undef("",undef) returns 0. (Not sure)
So you'd need to treat the 3 extra cases for $a, $b being undef and return -1,0,1 accordingly.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sort undef
by SuicideJunkie (Vicar) on Jun 12, 2017 at 16:19 UTC | |
by LanX (Saint) on Jun 12, 2017 at 16:29 UTC | |
Re^2: Sort undef
by LanX (Saint) on Jun 12, 2017 at 13:35 UTC | |
by choroba (Cardinal) on Jun 12, 2017 at 13:55 UTC | |
by LanX (Saint) on Jun 12, 2017 at 14:18 UTC | |
by AnomalousMonk (Archbishop) on Jun 12, 2017 at 15:44 UTC |
In Section
Seekers of Perl Wisdom