Script Preparation code:
x
 
array = Array.from({
    length: 50
}, (x, i) => (Math.round(Math.random() * (i + .01) * 1000)))
sortNumeric = (a, b) => (Number(a) - Number(b));
Tests:
  • Array.sort()

     
    array.sort(sortNumeric);
  • Array.toSorted()

     
    array.toSorted(sortNumeric)
  • [...Array].sort()

     
    [...array].sort(sortNumeric);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Array.sort()
    Array.toSorted()
    [...Array].sort()

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 19 days ago)
Mozilla/5.0 (X11; CrOS x86_64 14695.114.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36
Chrome 102 on Chrome OS 14695.114.0
View result in a separate tab
Test name Executions per second
Array.sort() 147144.2 Ops/sec
Array.toSorted() 0.0 Ops/sec
[...Array].sort() 65389.5 Ops/sec