#!/usr/bin/perl use Modern::Perl; say "\n\n\t sort on multiple keys"; my @first = qw(John Joe John Jon Fred Rich); my @last = qw(Smith Smith Jones Jackson Jones Adler); my @index = sort { $last[$a] cmp $last[$b] or $first[$a] cmp $last[$b] } 0 .. $#first; for (@index) { say "$last[$_], $first[$_]"; } say "\n \t But, testing, single sort (cmp):"; my @sorted = sort { $a cmp $b } qw(John Joe John Jon Fred Rich); for (@sorted) { say "\t $_"; } =head execution sort on multiple keys Adler, Rich Jackson, Jon Jones, John Jones, Fred Smith, John Smith, Joe But, testing, single sort (cmp): Fred Joe John John Jon Rich ## sort puts "John" before "Joe" in the first instance but not in the second: Why? =cut