What is the benefit for a sort algorithm to be stable?

后端 未结 10 2424
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 22:35

A sort is said to be stable if it maintains the relative order of elements with equal keys. I guess my question is really, what is the benefit of maintaining this relative o

10条回答
  •  孤城傲影
    2020-12-12 23:40

    It means if you want to sort by Album, AND by Track Number, that you can click Track number first, and it's sorted - then click Album Name, and the track numbers remain in the correct order for each album.

提交回复
热议问题