Which sorting algorithm is best suited to re-sort an almost fully sorted list?

后端 未结 4 1319
再見小時候
再見小時候 2020-12-17 21:42

I have a list of strings which has been sorted by a specific comparison function.

Now I have to re-sort this list using a different comparison function.

4条回答
  •  爱一瞬间的悲伤
    2020-12-17 22:15

    As I understood your data list is allready sorted (let say by ascii/country charset order), but without some dictionary rules applied for particular country. For example Germany and their Umlauts

    see Germanic_umlaut in wikipedia

    you are not inserting new items, you just want to resort them by little bit more strict sorting rule.

    as you can read for example here

    http://www.softpanorama.org/Algorithms/Sorting/bubblesort.shtml

    bubble sort works well on allready sorted lists with just a few permutations. This sounds like bubble sort is good algorithm to start with. Also note that bubble sort is "stable" sorting algorithm. This could be important for your scenario.

提交回复
热议问题