note
Aristotle
<p>Generally I use an extra array for extracted keys and then use it to sort indices.</p>
<code>
my @sorted = do {
my @key = map { lc substr $_->[ 4 ], 0, 3 } @a_of_a;
my @idx = sort { $key[ $a ] cmp $key[ $b ] } 0 .. $#key;
@a_of_a[ @idx ];
};
</code>
<p>That’s much easier to follow than the ST. Additionally, it uses orders of magnitude less memory for large datasets because it doesn’t create zillions of tiny anonymous arrays. (I love Perl’s effortless data structures and what they enable, I really do, but roughly 100 bytes of overhead for an empty array… talk about wasteful.) It’s also faster for the same reason. In fact, it’s a speed demon – as fast as it gets without a GRT, or possibly faster if the transform you need for your GRT is costly.</p>
<p>What’s not to like? I see very little reason to use a classic ST.</p>
<p align="right" class="pmsig pmsig-114691"><i>Makeshifts last the longest.</i></p>
561229
561528