stable sort

A sort that keeps items with equal keys in the same relative order they had before sorting.

In more detail

Stability lets you sort by several keys in passes: sort by the secondary key first, then stably by the primary key. Merge sort, insertion sort and Python's sorted() are stable; quicksort and heap sort usually are not.

Related terms

Taught in

References