Created
December 15, 2015 15:44
-
-
Save eternal44/f762e8a81abeab2f8eed to your computer and use it in GitHub Desktop.
Custom 'sort' function
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
var sort = function(arr){ | |
var newArray = []; | |
var copyOfArr = arr; | |
var count = arr.length; | |
while(copyOfArr.length > 0){ | |
var minIndex = copyOfArr.indexOf(Math.min.apply(null, arr)); | |
newArray.push(Number(copyOfArr.splice(minIndex, 1))); | |
} | |
return newArray; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried using the find function but I got an error so I made my own (line 7).