map{print "$_->[0]\n"} sort {$a->[1] cmp $b->[1]} map{[$_, (split)[2]]} @lines;