Skip to content

Array.prototype.sort compareFunction expects a number to be returned. - #24

Open
dgalvez wants to merge 1 commit into
elijahmanor:masterfrom
dgalvez:master
Open

Array.prototype.sort compareFunction expects a number to be returned.#24
dgalvez wants to merge 1 commit into
elijahmanor:masterfrom
dgalvez:master

Conversation

@dgalvez

@dgalvez dgalvez commented Apr 7, 2021

Copy link
Copy Markdown

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
This was causing a buggy behaviour when variable names were substrings of other variable names.

Example:
JSON.stringify(["hola", "holab", "ho"].sort( ( x, y ) => false )) === JSON.stringify(["hola", "holab", "ho"].sort( ( x, y ) => true ))

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
This was causing a buggy behaviour when variable names were substrings of other variable names.

Example:
JSON.stringify(["hola", "holab", "ho"].sort( ( x, y ) => false )) === JSON.stringify(["hola", "holab", "ho"].sort( ( x, y ) => true ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant