Added the sorting algorithm.