1 4 package com.tonbeller.wcf.utils; 5 6 import java.util.Comparator ; 7 import java.util.List ; 8 9 16 public class IndexOfComparator implements Comparator { 17 18 List list; 19 20 public IndexOfComparator(List list) { 21 this.list = list; 22 } 23 24 public int compare(Object o1, Object o2) { 25 int i1 = list.indexOf(o1); 26 int i2 = list.indexOf(o2); 27 if (i1 < 0 && i2 < 0) 28 return 0; 29 if (i1 < 0) 30 return 1; 31 if (i2 < 0) 32 return -1; 33 if (i1 > i2) 34 return 1; 35 if (i1 < i2) 36 return -1; 37 return 0; 38 } 39 } 40 | Popular Tags |