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; |
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 |
} |
} |