JSTable icon indicating copy to clipboard operation
JSTable copied to clipboard

Sort values descending, nulls last

Open hv92 opened this issue 3 years ago • 1 comments

Hi there!

At the moment the default of this script is sort the values in ascending order with nulls last. But when I try to sort the values in descending order, the nulls values appear on the top. Is there a way to move the null values to the bottom (and also keeping nulls last when sorting in ascending order)?

It should be around lines 492-518 in jstable.js, but it's hard to understand what's happening there exactly.

Thanks!

hv92 avatar Aug 07 '22 09:08 hv92

Hey @hv92,

your feature request is currently not implemented. As you already found out the sorting is done in the mentionen rows. Therefore the JavaScript sorting (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description) with a custom sorting algorithm is used. The custom sorting algorithm removes some possible prefixes/suffixes to enable sorting of additional values. Additionally empty values are sorted to the top. Feel free to submit a pull request with an option to inverse this behaviour.

Trekky12 avatar Aug 23 '22 17:08 Trekky12