Stable sorting algorithm
Formally stability may be defined as, how the algorithm treats equal elements. Let A[] be an array, and let ‘<‘ be a strict weak ordering on the elements of A[].  A sorting algorithm is stable if: i < j and A[i]=A[j] implies pi(i) < pi(j) where pi is the sorting permutation (sorting moves A[i] to position pi(i)).