Va bene ... dai un'occhiata a

http://it.wikipedia.org/wiki/Algoritmo_di_ordinamento