Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.sort with strings vs arrays
(version: 1)
Comparing performance of:
sort by array vs sort by string
Created:
one month ago
by:
Guest
Jump to the latest result
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; });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
sort by array
sort by string
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Browser/OS:
Chrome 145 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
sort by array
164.9 Ops/sec
sort by string
323.0 Ops/sec
Related benchmarks:
Lodash sort vs array.prototype.sort small sample
R.sort vs es6 sort
Lodash _.sort vs array.prototype.sort1
Lodash sortBy vs orderBy 4.17.21
Lodash sort vs array.prototype.sort reverse
Lodash 4.17.21 sort VS array.prototype.sort
Lodash sort vs array.prototype.sort
Sorting test U
Lodash sort vs array.prototype.sort smaller set
Comments
Confirm delete:
Do you really want to delete benchmark?