in reply to In-place sort with order assignment
I believe @a = sort @a; works in place. O(1N) memory, O(NN log N) time.
my @keys; keys(%hash); # Reset iterator #while (my $k = each(%hash)) { # if 0 or '' are possible keys while (my $k = each(%hash)) { push @keys, $k; } @keys = sort @keys; for (0..$#keys) { $hash{$keys[$_]} = $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: In-place sort with order assignment
by BrowserUk (Patriarch) on Sep 20, 2010 at 14:00 UTC | |
by ikegami (Patriarch) on Sep 20, 2010 at 14:27 UTC | |
by BrowserUk (Patriarch) on Sep 20, 2010 at 16:27 UTC |