Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于这样的问题 - 如何对每个整数由 10 位表示的整数数组进行排序?我相信我们可以使用计数排序。但是如果我将问题稍微调整为每个项目是整数和字符串的组合,并且问题要求数组根据整数值进行排序,如何解决这个问题?
您仍然可以使用 bin 排序,例如计数排序。仍然会有 1024 个 bin,但不是保存计数,每个 bin 都保存一个字符串列表,其中包含相应的整数键。
如果需要,您可以单独对每个 bin 中的字符串进行排序。为此,最好使用快速排序之类的比较排序。