Skip to content

DataFrame.OrderBy(string columnName) does not perform stable sorting! #6443

Open
@AsimZaid

Description

@AsimZaid

Stable sorting preserves the order of entries in the input when their sorting keys are same. Please see the below link:
https://stackoverflow.com/questions/1517793/what-is-stability-in-sorting-algorithms-and-why-is-it-important

As an example:
Before sorting...

df
A     B     C
9     18    28
6     11    25
6     10    23
3     16    26
6     13    21
3     19    22
3     11    28
6     17    20

After sorting...

df.OrderBy("A")
A     B     C
3     16    26
3     11    28
3     19    22
6     11    25
6     10    23
6     17    20
6     13    21
9     18    28

The three rows where column A = 3, should be ordered with column B as 16,19,11 (not 16,11,19).
The four rows where column A = 6, should be ordered with column B as 11,10,13,17 (not 11,10,17,13).

If we get a stable sorting with OrderBy function, we would have a work-around for multi-column sorting which is not yet available according to #5758 and #5649. For those interested in the workaround, please see this question on stackoverflow.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Microsoft.Data.AnalysisAll DataFrame related issues and PRsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions