React-table: Custom sort function using the `sortType` works only in one direction.

Created on 29 Jan 2020  路  2Comments  路  Source: tannerlinsley/react-table

Hi there! First of all thanks for all your efforts in creating such a great component. However I did encounter a rather strange issue.Briefly, when I use a custom function for sorting, the results are sorted for one direction only. The second direction restores the unsorted order of rows.
Here is a small example.
In chrom/edge it performs only the descending sorting, in firefox - ascending. Am I missing something?

Thanks and best regards,
Vlad

Most helpful comment

@Hillelman Thanks!

All 2 comments

Hi @vigor-vlad, first of all, thank you very much for sharing your code, it helped me to solve mine.
In order to fix yours, your comparison function has to return one of the three possible values:
Negative (if B is bigger than A)
Zero (if A and B are equal)
Positive (if A is bigger than B)

For more info, see the 'Parameter Values' section in this page:
https://www.w3schools.com/jsref/jsref_sort.asp

@Hillelman Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kieronsutton00 picture kieronsutton00  路  3Comments

monarajhans picture monarajhans  路  3Comments

bdkersey picture bdkersey  路  3Comments

Abdul-Hameed001 picture Abdul-Hameed001  路  3Comments

missmellyg85 picture missmellyg85  路  3Comments