# Perl 6, <s>28</s> 25 bytes <!-- language-all: lang-perl6 --> {.flat.sort.rotor(+.[0])} This takes a list of lists (not arrays).