Are the sorting algorithms used by NSArray stable sorts?

前端 未结 3 625
盖世英雄少女心
盖世英雄少女心 2020-12-11 15:41

Are the sorting algorithms used by the various sorting methods in NSArray stable? (As in are they \"stable sort\" algorithms, where items with the same sort key have their

3条回答
  •  余生分开走
    2020-12-11 16:27

    In the doc, no details are given as to the final order of identical items.

    Therefore, I feel making any assumptions about the order would be a bad idea. Even if you determine experimentally what the order is, this could change based on the number of items in the array or which version of iOS runs the sort.

    For me, I would stick with the promises provided by documentation.

提交回复
热议问题