Last active
March 16, 2018 12:38
-
-
Save josephrexme/68526f00ad007ec678429972a0523242 to your computer and use it in GitHub Desktop.
Trump sorting algorithm based on https://medium.com/@gantlaborde/trump-sort-a-new-sorting-algorithm-b37b1133356a#.mqkj9dlxj
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
const TrumpSort = (arr) => { | |
let pushArray = [0]; | |
let wallHeight = pushArray[pushArray.length - 1]; | |
arr.forEach((v, i) => { | |
if(v > wallHeight) pushArray.push(v); | |
}); | |
pushArray.shift(); | |
return pushArray; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment