/[projects]/dao/DaoAdresseService/src/main/java/dk/daoas/daoadresseservice/util/NaturalOrderComparator.java
ViewVC logotype

Diff of /dao/DaoAdresseService/src/main/java/dk/daoas/daoadresseservice/util/NaturalOrderComparator.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2536 by torben, Fri May 8 20:25:12 2015 UTC revision 2537 by torben, Mon May 11 07:57:19 2015 UTC
# Line 35  misrepresented as being the original sof Line 35  misrepresented as being the original sof
35    
36  public class NaturalOrderComparator<T> implements Comparator<T>, Serializable  public class NaturalOrderComparator<T> implements Comparator<T>, Serializable
37  {  {
38      int compareRight(String a, String b)          private static final long serialVersionUID = 1L;
39    
40            int compareRight(String a, String b)
41      {      {
42          int bias = 0;          int bias = 0;
43          int ia = 0;          int ia = 0;
# Line 179  public class NaturalOrderComparator<T> i Line 181  public class NaturalOrderComparator<T> i
181              "pic 5 something", "pic 6", "pic   7", "pic100", "pic100a", "pic120", "pic121",              "pic 5 something", "pic 6", "pic   7", "pic100", "pic100a", "pic120", "pic121",
182              "pic02000", "tom", "x2-g8", "x2-y7", "x2-y08", "x8-y8" };              "pic02000", "tom", "x2-g8", "x2-y7", "x2-y08", "x8-y8" };
183    
184          List orig = Arrays.asList(strings);          List<String> orig = Arrays.asList(strings);
185    
186          System.out.println("Original: " + orig);          System.out.println("Original: " + orig);
187    
188          List scrambled = Arrays.asList(strings);          List<String> scrambled = Arrays.asList(strings);
189          Collections.shuffle(scrambled);          Collections.shuffle(scrambled);
190    
191          System.out.println("Scrambled: " + scrambled);          System.out.println("Scrambled: " + scrambled);
192    
193          Collections.sort(scrambled, new NaturalOrderComparator());          Collections.sort(scrambled, new NaturalOrderComparator<String>());
194    
195          System.out.println("Sorted: " + scrambled);          System.out.println("Sorted: " + scrambled);
196      }      }

Legend:
Removed from v.2536  
changed lines
  Added in v.2537

  ViewVC Help
Powered by ViewVC 1.1.20