Sorting Performance (v5)

Revision 5 of this benchmark created on


Description

Checking if the inbuilt .sort() is faster than a our own sort.

Setup

const letterList = ["c", "b", "g", "f", "n"];

Test runner

Ready to run.

Testing in
TestOps/sec
Function sort
console.log(letterList.slice().sort((a, b) => a.localeCompare(b)));

ready
Function expanded sort
console.log(letterList.slice().sort((a, b) => {
    if (a < b) return -1;
    if (a > b) return 1;
    return 0;
}));
ready
Inbuilt sort
console.log(letterList.sort())
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.