in reply to In-place sort with order assignment
Now, assuming that doesn't work you can take a multi-pass approach using each (which consume almost no memory). Essentially, you have two data structures designed to maintain order (pick your poison). One the first pass, you keep track of the bottom N elements leaving the 2nd data structure empty. On the second pass, you start recording the next bottom N elements while assigning the values of the first N. On the 3rd pass they swap functions. Wash, rinse, repeat.my $cnt = 0; for (sort keys %hash) { $hash{$_} = ++$cnt; }
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: In-place sort with order assignment
by BrowserUk (Patriarch) on Sep 19, 2010 at 14:30 UTC | |
by Marshall (Canon) on Sep 19, 2010 at 23:17 UTC | |
by dasgar (Priest) on Sep 20, 2010 at 00:48 UTC | |
by Marshall (Canon) on Sep 20, 2010 at 03:46 UTC | |
by dasgar (Priest) on Sep 20, 2010 at 05:06 UTC | |
by BrowserUk (Patriarch) on Sep 20, 2010 at 07:53 UTC | |
by Limbic~Region (Chancellor) on Sep 19, 2010 at 14:48 UTC | |
by BrowserUk (Patriarch) on Sep 19, 2010 at 15:04 UTC | |
by Limbic~Region (Chancellor) on Sep 19, 2010 at 15:21 UTC | |
by BrowserUk (Patriarch) on Sep 19, 2010 at 15:37 UTC | |
|