HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
 
var generateText = function(){
  return  Math.random().toString(36).substring(2, 4);
}
var arr = []
for(i=0; i<100; i++){
    const obj = {}
    obj.id = i;
    obj.text = generateText()
    arr.push(obj)
}
Tests:
  • _.orderBy

     
    _.orderBy(arr, ['text'], ['desc'])
  • Array.sort

     
    arr.sort((a, b) => a.text - b.text)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    _.orderBy
    Array.sort

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36
Chrome 101 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
_.orderBy 25481.5 Ops/sec
Array.sort 143906.9 Ops/sec