Derek Fountain
Here's a perl script for you ################################################ #!/usr/bin/perl open (FH,"<$ARGV[0]") or die $!; @array = <FH>; my @sorted = sort @array; open (FH,">$ARGV[0].sorted") or die $!; print FH @sorted; close FH; ##############################################
Is that not just a very longhand way of saying:
perl -e 'print sort <>' < file > file.sorted
Anyway, both don't sort according to the current locale while the command "sort" does. See perllocale: USING LOCALES The use locale pragma By default, Perl ignores the current locale. The "use locale" pragma tells Perl to use the current locale for some operations: The comparison operators ("lt", "le", "cmp", "ge", and "gt") and the POSIX string collation functions strcoll() and strxfrm() use "LC_COLLATE". sort() is also affected if used without an explicit comparison function, because it uses "cmp" by default. -- Alexandr.Malusek@imv.liu.se