operator vs localeCompare

Benchmark created by Andreas Goebel on


Preparation HTML

<script>
  var arr = [{
   value: '10Foo'
  },
  {
   value: '05Javascript'
  },
  {
   value: 'MooTols'
  },
  {
   value: 'Zebra'
  },
  {
   value: 'Ape'
  }];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
operator
arr.sort(function(a, b) {
 return a.value > b.value;
});
ready
localeCompare
arr.sort(function(a, b) {
 return a.value.localeCompare(b.value);
});
ready

Revisions

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

  • Revision 1: published by Andreas Goebel on