danfojs icon indicating copy to clipboard operation
danfojs copied to clipboard

String Series sortValues is Backwards

Open sernst opened this issue 2 years ago • 0 comments

Describe the bug

When sorting a column of strings, ascending and descending behaviors are reversed.

To Reproduce

>> s = new dfd.Series(["2015-01-01", "2023-01-01", "2017-01-01", "2010-01-01"])

// 1. Sort values by default order, which from documentation says is ascending...
>> s.sortValues().values
//    Array(4) [ "2023-01-01", "2017-01-01", "2015-01-01", "2010-01-01" ]

// 2. Set explicit ascending: true...
>> s.sortValues({ ascending: true }).values
//    Array(4) [ "2023-01-01", "2017-01-01", "2015-01-01", "2010-01-01" ]

// 3. Set explicit ascending: false...
>> s.sortValues({ ascending: false }).values
//    Array(4) [ "2010-01-01", "2015-01-01", "2017-01-01", "2023-01-01" ]

Expected behavior I would expect string series ascending sort order to be ascending, and specifically match Array.sort ascending behavior strings.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS, Windows
  • Browser: Firefox, Chrome
  • Version: 115, 114

sernst avatar Jul 24 '23 13:07 sernst