Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.sort with strings vs arrays
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Browser:
Chrome 145
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one month ago
Test name
Executions per second
sort by array
164.9 Ops/sec
sort by string
323.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var arrayToSort = []; function getRandom() { return Math.random() * 10 % 10; } for (var i = 0; i < 10000; ++i) { arrayToSort.push({ a: getRandom(), b: getRandom() }); }
Tests:
sort by array
arrayToSort.sort(function(a, b) { a = [ a.a, a.b ]; b = [ b.a, b.b ]; return a < b ? -1 : 1; });
sort by string
arrayToSort.sort(function(a, b) { a = a.a + ':' + a.b; b = b.a + ':' + b.b; return a < b ? -1 : 1; });