in reply to Re^2: Array Sort
in thread Array Sort
All in all, I wonder if there is ever a situation where the ST makes sense?
Over plain sort, sure. Over GRT? Not so much.
ST can return objects, whereas GRT returns strings unless an external array is used.
ST can produce simpler and more readable code than GRT in some circumstances.
However, ST isn't as fast as GRT.
# ST my @fhs = map $_->[0], sort { $a->[1] <=> $b->[1] } map [ $_, fileno($_) ], get_fhs();
# GRT my @fhs = get_fhs(); @fhs = map $fhs[ unpack('x4 N', $_) ] sort map pack('NN', fileno($fhs[$_]), $_), 0..$#fhs;
# GRT my @fhs = get_fhs(); @fhs = @fhs[ map unpack('x4 N', $_), sort map pack('NN', fileno($fhs[$_]), $_), 0..$#fhs ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Array Sort
by BrowserUk (Patriarch) on May 10, 2011 at 19:53 UTC |