Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Odd sorrting
(version: 0)
Odd sorrting
Comparing performance of:
array methods vs for x 2
Created:
3 years ago
by:
Guest
Jump to the latest result
Tests:
array methods
const arr = [-6, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -4, -5, -3]; let indexes = [], values = []; arr.map((el, index) => { if(el % 2 !== 0) { indexes.push(index); values.push(el); } }) let filtered = arr.filter((el,i) => { // console.log(el); // console.log(i); return el % 2 === 0; }) indexes.sort((a,b) => { return a-b;}); values.sort((a,b) => { return a-b;}) for(let i=0; i<values.length; i++) { filtered.splice(indexes[i], 0 , values[i]) }
for x 2
const arr = [-6, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -4, -5, -3]; let arrOdd = [] for(let i = 0; i<arr.length; i++) { if(arr[i] % 2 !== 0) { arrOdd.push(arr[i]); arr[i] = null; } } arrOdd.sort((a,b) => {return a-b}); for(let i = 0; i<arr.length; i++) { if(arr[i] == null) { arr[i] = arrOdd.shift(); } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
array methods
for x 2
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
SJCL sym vs asym
SJCL sym vs asym
String double reverse
Reverse array
Decoding batching vs text decoder
Comments
Confirm delete:
Do you really want to delete benchmark?