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[$_]} = $_; }
In reply to Re: In-place sort with order assignment
by ikegami
in thread In-place sort with order assignment
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |