Re: sort without ignoring hyphens



On Mar 29, 4:19 pm, kra...@xxxxxxxxx (John W. Krahn) wrote:
tc...@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.

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


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
(in ASCII order: hyphen (ascii 45) then 0-9 (ascii 48-57) then A-Z
(ascii 65-90))

TIA

.



Relevant Pages

  • Re: sort without ignoring hyphens
    ... ASCII order: hypen, 0-9, A-Z. ... It appears linux sort also has the problem. ... I want to avoid a brute force char by char sort if ...
    (perl.beginners)
  • Possible Problem with sort Command
    ... Here is the source that outputs strings to a file, executes the sort ... void main (int argc, char *argv) ...
    (linux.redhat)
  • Re: Possible Problem with sort Command
    ... Here is the source that outputs strings to a file, ... void main (int argc, char *argv) ... I assumed that sort would do a string comparison ... works in different ways based on LOCALE environment settings. ...
    (linux.redhat)
  • Re: sort without ignoring hyphens
    ... ASCII order: hypen, 0-9, A-Z. ... It appears linux sort also has the problem. ... I want to avoid a brute force char by char sort if ...
    (perl.beginners)
  • Re: sort without ignoring hyphens
    ... ASCII order: hypen, 0-9, A-Z. ... It appears linux sort also has the problem. ... I want to avoid a brute force char by char sort if ...
    (perl.beginners)