我想对一个用于显示给用户的ArrayList进行排序:
String[] listOne = {whip, amulet, cape};然后排序第二个ArrayList,它用作相对于正在排序的第一个列表的备份数据:
String[] listTwo = {abyssal_whip, amulet_of_power, strength_cape};有什么办法我能做到吗?
发布于 2015-03-08 04:37:54
不要将两个相关的数据存储在单独的数组中。
相反,创建一个包含这两部分数据的自定义对象。然后,您可以在类上实现Comparable,也可以编写自定义Comparator来为您进行排序。
例如,签出:Sorting using Comparator- Descending order (User defined classes)
例如,它向您展示了如何:
Comparator或实现Comparable。https://stackoverflow.com/questions/28923097
复制相似问题