[Feature Request]: Allow the table sortingComparator to distinguish sorting direction #3053
Open
2 tasks done
Labels
enhancement
New feature or request
Description
Currently,
sortingComparator
takes in two items in a table and returns a number which is used to sort. E.g.:This works great when you're sorting data from a single property. However, I would like to display a range in a single column. E.g.:
I would like to be able to vary the comparator based on if the sort direction is ascending or descending.
E.g.:
(notice that the order when descending is a,b,c and when ascending is c,a,b which are not the reverse of eachother)
So if I want to find the shortest available term, I can sort ascending, but if I want to find the longest, I can sort descending.
This is currently not really possible, as the
sortingComparator
only takes in 2 arguments, and you can't pass a different comparator in each render (you get warned bycheckSortingState
, and it fails to sort. I haven't managed to fully understand why it fails to sort yet).I am also open to alternative suggestions about the best way to resolve this problem. I'm aware that breaking the range into two separate columns would work, but I don't think it's unreasonable to present a range in this way. There is no reference to such a decision in the usage guidelines.
This could be implemented in a few ways:
TableProps.ColumnDefinition
to add optionalsortingComparatorDesc
or similarThanks!
Code of Conduct
The text was updated successfully, but these errors were encountered: