2 |
# |
# |
3 |
|
|
4 |
use strict; |
use strict; |
|
use locale; |
|
5 |
|
|
6 |
# maximum entries |
# maximum entries |
7 |
my $max = 0; |
my $max = 0; |
61 |
push @lines, $_; |
push @lines, $_; |
62 |
} |
} |
63 |
|
|
64 |
# spaces will be ignored when sorting using locale. That's why we have |
foreach (sort { lc($a) cmp lc($b) } @lines) { |
|
# cache of lines with spaces replaced by exclamation mark (!) so that |
|
|
# sort order is strict and not dictionary. For more info, see: |
|
|
# http://archives.postgresql.org/pgsql-sql/2002-04/msg00266.php |
|
|
# http://groups.google.com/groups?selm=handler.82819.D82819.99045085113033.ackdone%40bugs.debian.org&output=gplain |
|
|
|
|
|
my %locale_space_fix; |
|
|
|
|
|
foreach (sort { |
|
|
unless($locale_space_fix{$a}) { |
|
|
my $tmp = $a; |
|
|
$tmp =~ s/ /!/g; |
|
|
$locale_space_fix{$a} = lc($tmp); |
|
|
} |
|
|
unless($locale_space_fix{$b}) { |
|
|
my $tmp = $b; |
|
|
$tmp =~ s/ /!/g; |
|
|
$locale_space_fix{$b} = lc($tmp); |
|
|
} |
|
|
$locale_space_fix{$a} cmp $locale_space_fix{$b}; |
|
|
} @lines) { |
|
65 |
|
|
66 |
my @data = split(/\t+/,$_); |
my @data = split(/\t+/,$_); |
67 |
|
|