Improved sort-csv helper function.