Created
July 6, 2017 20:55
-
-
Save Echooff3/dac42d23e07a6e1ea5c9069e2c68b61c to your computer and use it in GitHub Desktop.
XOR Sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let x = Array.from(new Array(10), () => {return (Math.random() * (20 - 1) + 1) | 0}) | |
const _xorSort = (x) => { | |
for( i = 0; i < x.length; i++) { | |
for( j = 0; j < x.length; j++) { | |
if(x[i] < x[j]) { | |
x[i] = x[i] ^ x[j] | |
x[j] = x[i] ^ x[j] | |
x[i] = x[i] ^ x[j] | |
} | |
} | |
} | |
return x | |
} | |
console.log(x) | |
_xorSort(x) | |
console.log(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment