Perl: the Markov chain saw | |
PerlMonks |
Re: Fastest way to sort a list of integers into 0,1,2,3,-3,-2,-1by choroba (Cardinal) |
on Feb 05, 2019 at 14:17 UTC ( [id://1229407]=note: print w/replies, xml ) | Need Help?? |
So first sort by signum, but zero go first, then sort normally:
Update: It seems comparable to grepfirst, thus slower than sortfirst. Update 2: This seems to be a bit faster than grepfirst, but still not as fast as sortfirst:
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In Section
Seekers of Perl Wisdom
|
|