Trump Sort — A new sorting algorithm
Making Sorting Algorithms Great Again

What is Trump Sort?
Trump Sort is an merciless O(n)
in-memory variation of the drop sort algorithm with political benefits baked in. The algorithm is extremely easy to write, explain, and it’s useful to any native english-speaking white male. Ask anyone! The benefits are yuge.
Start with a random list of values:

You begin by looping N times where N is the size of the array. You then either build a wall or deport along the set.
Let’s do this example as an exercise.
Compare the second item in the array against the first. If that second item is larger than the first, then that index is now your “wall”.

We continue moving along to the 3rd index where the value is lower than our wall. That 3rd item of the set is then deported to the end.

You continue on until you have performed the original N times, and something magical happens! 🎩

The wall is built! None of the deported items can return, because the wall is assured to be the tallest, and we didn’t have to pay for the wall! We can now safely ignore everything above the wall for our sorted list.

Not only did our algorithm sort quickly, build a wall and export unwanted items, it also decreased the size in memory! I’ve asked a lot of people, and they’ve said this is the best sorting algorithm out there. You can’t trump Trump Sort.
FAQ:
Q: What happens to the deported items from our list?
A: Who cares? Why does everyone keep asking this?
Q: Sort only costsO(n)
WOW! Who paid for the wall?
A: Trump Sort deserves credit, but did not pay for the wall.
Q: Why would I use this when it doesn’t actually work?
A: You’re being rude. APOLOGIZE!
Can you implement Trump Sort?
Give it a try! Implement Trump Sort in your favorite programming language, and link it in the comments.
I hope that everyone enjoys the humor of this blog post, regardless of political oblivion. Special thanks to the devs I was talking with when we came up with this (i.e. Andrew Brindamour, Matt Hargett et al.). Also special thanks to Unsplash for the header background.
