slice sort vs toSorted

Benchmark created on


Setup

const array = ['a', 'c', 'b']

Test runner

Ready to run.

Testing in
TestOps/sec
slice sort
const sortedA = array.slice().sort((a, b) => a.localeCompare(b))
ready
toSorted
const sortedB = array.toSorted((a, b) => a.localeCompare(b))
ready

Revisions

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