in reply to Re: Need help in sorting the array
in thread Need help in sorting the array
I believe this calls for an application of the GRT (untested):
Actually, what you have there is a ST (http://en.wikipedia.org/wiki/Schwartzian_transform). A GRT (http://www.sysarch.com/Perl/sort_paper.html) is characterised by having a simple lexical sort rather than requiring a routine. Like this:
$ perl -le ' > @arr = qw{ TEXT1 TEXT3 TEXT11 TEXT2 TEXT13 }; > print for > map { substr $_, 9 } > sort > map { sprintf q{%09d%s}, ( split m{(?<=[A-Z])(?=\d)} )[ 1 ], $_ +} > @arr;' TEXT1 TEXT2 TEXT3 TEXT11 TEXT13 $
I hope this is of interest.
Cheers,
JohnGG
Update: Added references.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Need help in sorting the array
by bv (Friar) on Dec 10, 2009 at 16:45 UTC | |
|
Re^3: Need help in sorting the array
by perlCrazy (Monk) on Dec 10, 2009 at 17:08 UTC |