in reply to Re: numeric sort on substring
in thread numeric sort on substring
I'm wondering why you add the complication of an inner anonymous array and a three-argument split. I think neither are necessary and, since split defaults to operation on $_ one argument suffices.
print for map { $_->[ 0 ] } sort { $a->[ 1 ] <=> $b->[ 1 ] || $a->[ 2 ] <=> $b->[ 2 ] } map { [ $_ , ( split m{,} )[ 1, 0 ] ] } <DATA>;
You could also use a Guttman Rosler transform.
print for map { substr $_, 8 } sort map { pack q{NNA*}, ( split m{,} )[ 1, 0 ], $_ } <DATA>;
I hope this is of interest.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: numeric sort on substring
by Jim (Curate) on Jan 08, 2011 at 00:14 UTC | |
by johngg (Canon) on Jan 27, 2011 at 13:39 UTC | |
by salva (Canon) on Jan 27, 2011 at 14:48 UTC |