Array Sort vs. lodash sort (v5)

Revision 5 of this benchmark created on


Preparation HTML

<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.2.1/lodash.min.js"></script>

Setup

var jsArrayTest = [];
    for (var i = 1000; i > 0; i--) {
      jsArrayTest.push([_.random(-1000, 1000), 'foo', 'bar'])
    }
    var lodashArrayTest = _.cloneDeep(jsArrayTest);
    var testArray = _.cloneDeep(jsArrayTest);

Test runner

Ready to run.

Testing in
TestOps/sec
JS Array sort
testArray.sort(function compare(a, b) {
  if (a[0] < b[0]) return -1;
  if (a[0] > b[0]) return 1;
  return 0;
});
ready
loDash
_.sortBy(lodashArrayTest, function(x) {
  return x[0];
});
ready

Revisions

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