Skip to content

Numbers followed by a letter are sorted differently if they start with zero #8

Description

@DeannaV

['02', '04', '15', '22', '099', '02B', '04B', '15B', '22B', '099B'].sort(natsort());

I expected the result to be ["02", "02B", "04", "04B", "15", "15B", "22", "22B", "099", "099B"]

The actual result was ["02B", "02", "04B", "04", "15", "15B", "22", "22B", "099B", "099"]

For numbers starting with zero, the numbers with B are sorted first. I expected that the numbers followed by a letter would always be after the number by itself.

Is this a bug or is it intended to be this way?

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions