My first and easiest solution to come up with based on sorting, generalize perfectly to the general case. I added a code snippet to the article to show.
So I don't think the complex solutions really have any particular merit. The most dead-simple approach of just sorting is better at generalizing and has better performance.
You don't need a partitioning algorithm, so you are falling into the same trap as the Python authors here ;-) You are looking for complex solutions when they are not needed. Interestingly it gives me a second datapoint about my hypthesis that there is something about Python development that leads people towards more complex solutions.
Perhaps the whole "batteries included" emphasis and the tons of Python libraries that exist leads people to focus more on finding libraries, more than thinking about solutions?
This is of course just crazy speculation on my part. I just cannot help but notice the trend even if I have zero data or statistics to backup my hunch.