| Learn | Algorithm - Sorting - Stability in sorting | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Stability in Sorting Stability in sorting means whether a sort algorithm maintains the relative order of the equals keys of the original input in the result output. So a sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input unsorted array. Consider a list of pairs: Now we will sort the list using the first element of each pair. A stable sorting of this list will output the below list: Because An unstable sorting will output the below list: Unstable sort may generate the same output as the stable sort but not always. Well-known stable sorts:
Well-known unstable sorts: Parameters
|
Read Article
https://develop.horje.com/learn/1434/reference