Skip to content

Changing meaning (or adding another flag) for has_nan=True, descending=True #234

Description

@seberg

We would like to add descending sorts in NumPy (numpy/numpy#31345), but one caveat is that the NaN sorting in NumPy should push NaNs to the end of the array in descending sorts.

However, the convention currently implemented here is the opposite: It considers NaNs like the largest possible value so that NaNs come first in a descending sort. This is a convention preferred e.g. by DataFrames (at least more common) I think, and has the advantage that the result differs from just flipping res[::-1] (for unstable sorts).

Adding another switch for it would probably not be hard, or if we expect no users of has_nan=True, descending=True one could change it (but it's an API break).

I would expect it is a relatively simple change otherwise.

CC @r-devulap maybe just for a quick thought (CC @MaanasArora for awareness).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions