my @files = map { $_->[1] } sort { $b->[0] cmp $a->[0] } map { [ ((not -d "$dir/$_") || 0) . lc $_, $_] } readdir $dh;