my @unsorted = qw( ... strings ... ); my @sorted; foreach (@unsorted) { my $word = lc($_); my $idx = binsearch { $a cmp $b } $word, @sorted; splice(@sorted, ~$idx, 0, $word) if ($idx < 0); } print(join("\n", @sorted), "\n");