no-stack-dub-sack / cs-playground-react

In-Browser Algorithm and Data Structures Practice
http://cs-playground-react.surge.sh/
MIT License
520 stars 91 forks source link

Benchmark for native sort() flawed? #83

Closed crazy4groovy closed 4 years ago

crazy4groovy commented 6 years ago

el.array.sort((a, b) => a > b) should be: el.array.sort((a, b) => a - b)

It's OK when I test with:

        var z = el.array.sort((a, b) => a - b)
        console.log(z[2], z[3], z[4]) // OK

But not:

        var z = el.array.sort((a, b) => a > b)
        console.log(z[2], z[3], z[4]) // Nope, eg => 1670 2056 1425 
no-stack-dub-sack commented 6 years ago

@crazy4groovy nice catch, whoops! Want to file a PR to fix it?