[sort-] allow z[ and z] to reverse col sort dir or ignore col #2688
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a modified version of a feature I prototyped in #1877.
It lets
z[
andz]
modify a column for sorting, while keeping the existing sort criteria if possible. This is very convenient when exploring data.There are three cases for these commands:
z[
andz]
in current visidata)This PR adds new behavior only for the other two cases, where the column is already in the sort criteria:
When the column is used for sorting, and the command sort direction matches the existing direction. Like
z[
for a column that is already in ascending order due to a previousz[
. The column will be removed from the sort criteria. Any existing sort criteria on columns that are higher in priority, is kept. Lower priority columns are dropped from the sort criteria.When the column is used for sorting, and the new direction is the opposite of the existing direction. Like
z[
for a column that is in descending order from a previousz]
. The column will reverse its sort direction. Existing sort criteria are handled the same as in case 2.(In current visidata, for cases 2 and 3, the column is added to the sort criteria again, uselessly, which is a bug that throws off the sort arrow indicators for future columns used for sorting.)