my @sorted_files = map {$_->[0]} sort {$b->[1] <=> $a->[1] or $a->[0] cmp $b->[0]} map {[$_, -s]} @files; #### my @sorted_files = sort {-s $b <=> -s $a or $a cmp $b} @files; #### sorted_files = files.sort_by {|f| [- test(?s, f), f]};