[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.
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.