Skip to content

.sort() doesn't work correctly #605

Description

@supersational
[2,11].sort() 
# expected (python):
[2,11]
# result of JavaScript's [2,11].sort()  (used by Transcrypt.__runtime__.js in __sort__)
[11,2]

This is a classic JavaScript 'gotcha' since it will sort the elements as if they were strings, even if the elements are all numbers! It will sort correctly for most small numbers making it a tricky bug to catch as well.

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions