in reply to Optimizing a sort function (wrap-around alpha)

Unless I'm missing something here, both of those last two solutions give the letters in the wrong order. The order requested is divider, after, before - not before, divider, after. The following should work:
use strict; use warnings; my $str = 'AFNMIWEBFASBPMLASIFBYRW'; my $mid = 'I'; my @sorting; push @{$sorting[($_ cmp $mid) + 1]}, $_ for split '', $str; $str = join '', @{$sorting[1]}, (sort @{$sorting[2]}), (sort @{$sortin +g[0]}); print $str;