csvsort: ascending sort for some columns, descending for others
csvsort is great, but would be even better if you could combine ascending and descending sort. Columns prefixed with a minus sign could be sorted descending. Like so:
csvsort -c 1,2,-3
to sort by column 1 ascending, 2 ascending and 3 descending.
Was just looking as csvkit and hit the same issue - need to order ascending on two columns - then descending on a third.
We'd have to use functools.cmp_to_key as the basic key function can't switch order for different columns.
So a problem with specifying "-3" is that this is interpreted as "the range from the first column up to 3", same as the cut command. We can maybe use ~ if that seems intuitive.
As an option, we can use csvsql:
$ csvsql --query "SELECT * FROM YourFile ORDER BY C1 ASC, C2 ASC, C3 DESC" YourFile.csv