Skip to content

Sorting by date string does not result in expected sort order. #308

Closed
@ghing

Description

@ghing

Describe the bug

Sorting by a "YYYY-MM-DD" date string does not sort the data in the expected sort order and is not consistent with sorting of those strings using Array.prototype.sort().

To Reproduce

In a Node.js REPL:

const dfd = require('danfojs-node');
const data = {
  date: [ '1974-02-19', '1955-12-06', '1963-11-18' ]
};
const df = new dfd.DataFrame(data);
df.sort_values({by: 'date'}).print();

Expected behavior

This table will be output:

date
0 1955-12-06
1 1963-11-18
2 1974-02-19

Observed behavior

This table is output

date
0 1974-02-19
1 1955-12-06
2 1963-11-18

Screenshots

N/A This is running in a Node.js REPL on MacOS 10.15.7.

Additional context

  • Node Version: 16.13.0
  • Danfo version: 0.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions