Re: sort without ignoring hyphens
- From: rob.dixon@xxxxxxx (Rob Dixon)
- Date: Sat, 29 Mar 2008 20:01:33 +0000
tc314@xxxxxxxxxxx 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.
It appears that your problem is more complex than you have diagnosed.
Look:
use strict;
use warnings;
use List::Util qw/shuffle/;
my @list = shuffle ('-', '0' .. '9', 'A' .. 'Z', 'a' .. 'z');
print join(',', @list), "\n";
print join(',', sort @list), "\n";;
**OUTPUT**
9,L,c,1,M,2,m,J,5,t,8,y,W,N,k,h,Y,b,f,E,q,P,X,-,Z,B,I,K,4,V,e,F,x,g,3,H,u,v,R,w,r,T,d,O,G,7,U,l,z,6,a,s,A,p,0,o,C,i,n,Q,j,D,S
-,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
Can you please show us the code and data that is causing you problems?
Rob
.
- References:
- sort without ignoring hyphens
- From: tc314
- sort without ignoring hyphens
- Prev by Date: Re: diff says memory exhausted need help with perl
- Next by Date: Re: Interpolate variable in a __DATA__ block
- Previous by thread: sort without ignoring hyphens
- Next by thread: Re: sort without ignoring hyphens
- Index(es):
Relevant Pages
|
|