Konrad Foerstner wrote: > Hi Folks! > > My problem: I have a file of ids like a.12.34 or z.9.234 and want to sort > it into a new file. As the sort function sorts digit by digit I can't use > it (not so easy). Additionally the data file is quite big (11M) so I don't > know if it is okay to work with such big array. > > I hope someone could help me on some parts of my problem. > > cu > > Konrad
so you want to sort the first character field and then the second numeric field and then the third numeric field, etc right? try something like: #!/usr/bin/perl -w use strict; my @fields = qw(a.23.45.12 w.43.65.2.2 k.43.1.6.4 k.1.2.3 k.7.4 c.0243094.8); print join('.',@$_,"\n") for(sort {$a->[0] cmp $b->[0] || $a->[1] <=> $b->[1]} map{[split(/\./)]} @fields); __END__ prints: a.23.45.12 c.0243094.8 k.1.2.3 k.7.4 k.43.1.6.4 w.43.65.2.2 the program only sorts it until the second numeric field but you can modify it to go any level down. you also mention that the data will be coming from a file, so i am sure you can modify the above for that purpose as well. :-) if you are using [L|U]nix, you will probably want to check out the sort program as well. man sort david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]