in reply to sort empty string

Using a custom sort routine, you can redefine the sort behavior for a specific condition. Here's an example of something that always puts empty strings last, but otherwise sorts alphabetically:
sub by_blanklast { if (!length($a->[0]) ^ !length($b->[0])) { return length($b->[0]) - length($a->[0]); } return $a->[0] cmp $b->[0]; }
You can use this in your code like this:
 } sort by_blanklast map {
In my testing, this seems to work like you want.