Push swap: which algorithm to choose? - jgrigorjeva/push_swap GitHub Wiki
The push_swap project is one of the mandatory projects at 42 schools. Your goal is to sort a set of numbers using a limited set of operations, which means you must carefully choose the right sorting algorithm—or even develop your own. Finding the best approach can be quite a challenge, so I’m here to help you get started.
The project is nicely described on the 42-cursus gitbook page, have a look in there.
I experimented with two algorithms from the selection below. At first, I fell in love with radix sort—it seemed so simple and elegant. It was indeed easy to implement, but its results were far from ideal. I explored several optimizations to reduce the number of operations needed to sort the stack, and while some helped slightly, they weren’t enough to make it viable. It was disappointing to abandon radix sort, but I had to move on.
My second choice was the "Turk" algorithm. It appeared much more complex, but consistently delivered great results. However, I couldn’t help myself—I had to optimize the Turk algorithm even further.
Let’s explore the details in the next sections!
TL;DR: Go for Turk, if you want to save yourself some time ;)