Why make selection sort stable?

43 Views Asked by At

I am currently learning algorithms. While learning selection sort I came to know that selection sort is unstable as it swaps two elements. It can be made stable by inserting elements instead of swapping.

So if we have a array a = {2a ,2b, 1}

Unstable selection sort, sorts a={1, 2b ,2a}

and stable selection sort, sorts s a={1, 2a ,2b}

But actually the output is the same a={1, 2, 2}

So should I be concerned about selection sort being stable or unstable? There might be something I am missing.

TL;DR

In which cases I might need a stable selection sort?
0

There are 0 best solutions below