Sort map entries with or without explicit comparison?

Benchmark created on


Setup

entries = [
	["1", {a:7,b:6}],
	["01", {a:8,b:3}],
	["001", {a:9,b:6}],
	["00011", {a:1,b:0}],
	["00010", {a:2,b:0}],
	["00001", {a:3,b:6}],
	["000001", {a:4,b:6}],
]

Test runner

Ready to run.

Testing in
TestOps/sec
First element sort (string comparisons on entry[0])
entries.sort(
	(e1,e2)=>
	(e1[0]===e2[0])? 0 : (e1[0]>e2[0] ? 1:-1)
)
ready
Default sort (whole array to string)
entries.sort()
ready

Revisions

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