in reply to Pimp my code - Schwartzian transform maybe?
use Sort::Key::Multi qw(i3_keysort); # i3_keysort => sorter sub that expects # three integer keys print join "\n", map "$_->[0] $_->[1] $_->[2]", i3_keysort { my ($type, $item, $index) = @$_; my ($ix1, $ix2) = $index =~ /^(\d+)\.(\d+)$/; my $flag = flagValue($tagTypes{$item}[2]); $flag = -$flag if $type eq 'off'; ($ix1, $ix2, $flag) } @tagIndexes;
note that the type and flag properties can be easily collapsed on an unique index.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pimp my code - Schwartzian transform maybe?
by salva (Canon) on May 07, 2006 at 13:14 UTC |