Skip to content

Instantly share code, notes, and snippets.

@eternal44
Created December 15, 2015 15:44
Show Gist options
  • Save eternal44/f762e8a81abeab2f8eed to your computer and use it in GitHub Desktop.
Save eternal44/f762e8a81abeab2f8eed to your computer and use it in GitHub Desktop.
Custom 'sort' function
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;
};
@eternal44
Copy link
Author

I tried using the find function but I got an error so I made my own (line 7).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment