I often use a solution more or less like this, that is based on a hash where the key is the value to be sorted (and in this case is case-insensitive) and the value is the actual string to be printed. It's quite compact and it kills dupes for free. As in this case I don't want it to kill dupes, I append an unique counter to the key so that each key is guaranteed to be unique.
Here's the code:
use strict;
my %hDat;
my $d;
my $n;
map( ($hDat{lc $_ . $n++} = $_), <DATA> );
foreach $d (sort keys %hDat) { print $hDat{$d}; }
__DATA__
a
B
c
D
E
Aa
Xx
A
And here's the result:
a
A
Aa
B
c
D
E
Xx
You know, there is more than one way. :-)