views:

211

answers:

5

I know there are some like:

And there are some impractical ones like:

Some of the above use comparisons and others do not.

Do you know which other Efficient Algorithms or Techniques for sorting numbers exist? You can suggest me one even if it is not applicable in real life or it is impractical but it must be efficient, but it would be better if it is a computational solution.

+3  A: 

Python uses an algorithm called timsort.

Ned Batchelder
Thx I will take a look at this one.
Enrique
timsort is a mergesort. Various hoops have been jumped through to insure against bad worst-case performance.
dmckee
+5  A: 

Spaghetti sort: You cut lengths of spaghetti to lengths corresponding to numbers you want to sort. Then you tap the bundle of spaghetti down on the table so that all their ends align. Then you pick out the longest ones in order. The setup time is long, but the actual sorting time is constant.

Wikipedia has a whole category of sorting algorithms.

Paul Tomblin
Oh this one sounds interesting =)
Enrique
LOL. Speaking as a physicist here, if your working set gets to large (a function of the frictional properties of your spaghetti) this may become unreliable: at some point the tap down procedure may fail due to the force needed to hold the bundle together. I suggest using PTFE speghetti.
dmckee
It's linear, not constant.
GMan
"The setup time is long, but the actual sorting time is constant." And you get a tasty and nutritious meal out of it when you've finished.
itowlson
@GMan, the sorting time is constant - one tap, bam, and you're done. Reading the results is linear.
Paul Tomblin
What if we have values <= 0
Enrique
Actually, the sorting time is proportional to the length of the longest spaghetti. It takes time for the rest of the spaghetti to move that distance, remember.
Anon.
Pancake sort sounds more delicious. http://en.wikipedia.org/wiki/Pancake_sorting
Ewan Todd
That's how quantum computers work!
Pavel Shved
+1  A: 

There are sorting networks, which can be an efficient way of sorting if you know in advance how many items you have to sort.

Dan Dyer
+1  A: 

natural mergesort is different enough from "plain mergesort" to be worth mentioning separately (just like quickersort is enough of a variation on quicksort to be worth mentioning, but even more so). Python's timsort, which Ned's answer mentions, is based on natural mergesort, btw.

Oh, and, there's Dobosiewicz sort AKA "comb sort", which "stands to bubblesort as shellsort stands to insertion sort" (nothing especially efficient, but still worth mentioning).

Alex Martelli
A: 

A nice variation of Heapsort is Smoothsort. It performs better than Heapsort if the data is already almost sorted (O(n) instead of O(n log n)).

Whoever