in reply to "Swarming"

As stated before, this "divide and conquer" (also see http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm) approach can be applied to many problems, but you can also use hashes for this by maintaining your order in the values as such:
#!/usr/bin/perl @a = qw(one two three); %h = map({$_ => $count++} @a); print "$_ => $h{$_}\n" foreach (keys(%h)); foreach (sort( {$h{$a} <=> $h{$b}} keys(%h))) { print "$_\n"; }

Janitored by tye: Add CODE tags

Replies are listed 'Best First'.
Re^2: "Swarming"
by radiantmatrix (Parson) on Jul 20, 2006 at 19:37 UTC