Skip to content

setDistinct changes order #3602

@DavidMulder0

Description

@DavidMulder0

Nothing in the documentation for setDistinct implies anything about sorting the array/matrix, yet:

math.setDistinct([3, 1, 2]); // [1, 2, 3]
math.setDistinct(['h', 'e', 'l', 'l', 'o']); // ['e', 'h', 'l', 'o']

Expected

math.setDistinct([3, 1, 2]); // [3, 1, 2]
math.setDistinct(['h', 'e', 'l', 'l', 'o']); // ['h', 'e', 'l', 'o']

Docs: setDistinct

Code: .sort(compareNatural)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featuregood first issueRelatively localized/straightforward changes that would provide a good introduction to mathjs codehelp wanted

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions