On Mar 30, 10:57 pm, [EMAIL PROTECTED] (John W. Krahn) wrote: > [EMAIL PROTECTED] wrote: > > > On Mar 29, 4: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. > > > unsorted: > > 22 > > 2-2 > > 2-3 > > 23 > > 21 > > > linux sort produces: > > 21 > > 22 > > 2-2 > > 23 > > 2-3 > > > desired sort: > > 2-2 > > 2-3 > > 21 > > 22 > > 23 > > It appears to work in Perl: > > $ perl -le'@x = qw[22 2-2 2-3 23 21]; print for sort @x' > 2-2 > 2-3 > 21 > 22 > 23 > > 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- Hide quoted text - > > - Show quoted text -
I'm looking for the perl way of comparing strings. Your posted code 'diff says memory exhausted need help with perl Options' is the basis I want to build from. But it appears the gt,eq,lt comparisons ignore the hyphens in the strings. I really want to avoid slowing things to a crawl by doing brute force byte comparisons rather than string compares. (I'm really looking for a minimal patch to your code to produce the desired results.) Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/