table icon indicating copy to clipboard operation
table copied to clipboard

Table sorting doesn't work properly when column has the same value for each row

Open jeffcardoso opened this issue 8 years ago • 2 comments

Describe the bug When I switch the sort order of one column with the same value for each row, then the order becomes reversed.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/kmjw832rkr;
  2. Click the "Age" column header to sort ascending by age;
  3. Click the "Age" column header to sort descending by age;
  4. The order of rows becomes reversed although the age is the same for each row.

Expected behavior The rows order should remain the same.

Thanks in advance!

jeffcardoso avatar Oct 29 '18 12:10 jeffcardoso

Hi facing the same problem as @jeffcardoso said !!

hichamnaimi avatar Dec 03 '18 15:12 hichamnaimi

This is called stable sorting. It uses the original row index from your data as a fallback for equal values. This is intended for a large majority of use cases too, but if you want to override the sortBy or orderBy functions, React Table supports it.

tannerlinsley avatar Jan 31 '19 18:01 tannerlinsley