LC_ALL=C sort echo.txt
[EMAIL PROTECTED] wrote:
On Mar 29, 3:19 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
[EMAIL PROTECTED] wrote:
When I do string comparisons in perl the strings seem to ignore the
embedded hyphens.
I want to sort strings assuming the 'dictionary' order of the chars is
ASCII order: hypen, 0-9, A-Z.
It appears linux sort also has the problem (LC_ALL is blank).
Any ideas? I want to avoid a brute force char by char sort if
possible.
Please provide an *example* of your data, what it would look like if
sorted "properly", and what it actually looks like after being sorted.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
Given my data: (echo.txt)
21A
22A
2-4A
2-2A
23A
2-3A
08E
08F
08G
08GA
08H
08-J
I want perl (and linux sort) to see its order as:
08-J
08E
08F
08G
08GA
08H
2-2A
2-3A
2-4A
21A
22A
23A
However (on my system):
1) linux sort: sort echo.txt
produces the undesired result:
08E
08F
08G
08GA
08H
08-J
21A
22A
2-2A
23A
2-3A
2-4A
2) linux sort with -n: sort -n echo.txt
produces the undesired result:
2-2A
2-3A
2-4A
08E
08F
08G
08GA
08H
08-J
21A
22A
23A
3) perl's sort produces the DESIRED result
perl -le'@x = qw[21A 22A 2-4A 2-2A 23A 2-3A 08E 08F 08G 08GA 08H 08-
J]; print for sort @x'
08-J
08E
08F
08G
08GA
08H
2-2A
2-3A
2-4A
21A
22A
23A
So, how do I write a perl script to use in place of linux sort since
perl's sort
produces the desired results?
I want perlsort to accept input from STDIN or a filename as an argv.
I don't care about any command line options since perl seems to do
exactly
what I desire. (I thought perl's comparisons were wrong because I used
files sorted
by linux sort, my mistake.)
My files are significantly larger than physical memory.
Any help is appreciated.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/