Last active
October 20, 2015 13:32
-
-
Save omeroot/dcafc6fc287b9945cca5 to your computer and use it in GitHub Desktop.
This file contains 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
function swap(array, index1, index2) { | |
var temp = array[index1]; | |
array[index1] = array[index2]; | |
array[index2] = temp; | |
} | |
function WTFSorting(arr){ | |
var res = []; | |
res.push(arr[0]); | |
console.log(res); | |
for(var i = 1 ;i < arr.length ; i++){ | |
res.push(arr[i]); | |
console.log("before",res); | |
for(var j = 0 ; j< res.length - 1 ; j++){ | |
if(arr[i] < res[j]){ | |
this.swap(res, i, j); | |
console.log(res); | |
} | |
} | |
} | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment