1enum Code {
2 Str1(1), Str2(2), Str3(3), Str4(4), Str5(5));
3
4 int sortNumber;
5
6 Code(int sortNumber) {
7 this.sortNumber = sortNumber;
8 }
9
10 int returnNumber() {
11 return sortNumber;
12 }
13};
14
15public static void main(String[] args) {
16 List<Object> obj = new ArrayList<Object>();
17
18 Collections.sort(obj, new Comparator<Object>() {
19 @Override
20 public int compare(Object object1, Object object2) {
21 return Code.valueOf(object1.getStr()).returnNumber() > Code.valueOf(object2.getStr()).returnNumber() ? 1 : -1;
22 }
23 });
24}