my @video_ids = sort { ( $new_first ? $tmp{$b}{published} cmp $tmp{$a}{published} : $tmp{$a}{published} cmp $tmp{$b}{published} ) || $tmp{$a}{title} cmp $tmp{$b}{title} } @$ids;