in reply to Re: sort != sort
in thread sort != sort

Wow, I like that -- thanks much!
  1. Guaranteed O(n) -- right now, the comparisons are about 120% of n with normative mergesort and 102% of n with quicksort.
  2. I can pop those into the new array meaning the memory use will remain flat (rather than temporarily doubling).

my @bucket = (); while($#Notes >= 0) { my $n = shift @Notes; push @{$bucket[$n->{terms}-1]},$n; } #Need 1D array back: while($#bucket >= 0) { my $b = pop @bucket; push @Notes, shift @$b while ($#{$b} >= 0); }
Works perfect.