Skip to content

Array.sort: compare function return type #74

Closed
@cknitt

Description

@cknitt

Currently, the compare function for Array.sort/Array.sortInPlace is typed as

('a, 'a) => int

I do realize that this is also the signature used in OCaml's compare functions, but I wonder if the return type shouldn't be float instead for the ReScript/JS world. Looking at the MDN documentation for Array.sort, there is no need for the return type to be an integer, it is just about > 0, < 0 or === 0.

Using float instead of int would be more generic and allow us e.g. to use (a, b) => a -. b as a compare function for floats.

What do you think?

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