【发布时间】:2013-09-17 09:00:44
【问题描述】:
我需要根据特定的索引名称对 Set 数据进行排序。我有以下数据:
txt_4: somevalue
txt_2: somevalue
txt_1: somevalue
txt_0: somevalue
txt_3: somevalue
如何对这些数据进行排序?谢谢。
更新:
排序后的预期数据:
txt_0: somevalue
txt_1: somevalue
txt_2: somevalue
txt_3: somevalue
txt_4: somevalue
【问题讨论】:
-
使用
TreeSet,它将被整理出来。 -
您应该编写自己的
Comparator并使用有序的集合,例如TreeSet.