Insensitive sorting in react table v7 #2167
-
After sorting Lower cases are went down. Link: https://codesandbox.io/s/holy-voice-3zeqv?file=/src/App.js |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Below Code is working fine. Custom Sorting Code:const sortItems = (prev: Row, curr: Row, columnId: string) => { Column:{ |
Beta Was this translation helpful? Give feedback.
-
this doesn't quite work but it's on the right track. if you click the sort button three times in a row, it goes back to the column's original sort that happened on page load. i'm trying to figure out an issue, but might override this by sorting the data once before the table component mounts |
Beta Was this translation helpful? Give feedback.
Below Code is working fine.
Custom Sorting Code:
const sortItems = (prev: Row, curr: Row, columnId: string) => {
if (prev.original[columnId].toLowerCase() > curr.original[columnId].toLowerCase()) {
return 1;
} else if (prev.original[columnId].toLowerCase() < curr.original[columnId].toLowerCase()) {
return -1;
} else {
return 0;
}
};
Column:
{
Header: 'Sample Header',
accessor: 'sampleHeader',
sortType: (prev, curr, columnId) => {
return sortItems(prev, curr, columnId);
}
}