I got these code:
ListHandler<List<String>> columnSortHandler = new ListHandler<List<String>>(
list);
columnSortHandler.setComparator(nameColumn,
new Comparator<List<String>>() {
public int compare(List<String> o1, List<String> o2) {
if (o1 == o2) {
return 0;
}
// Compare the name columns.
if (o1 != null) {
return (o2 != null) ? o1.get(0).compareTo(o2.get(0)) : 1;
}
return -1;
}
});
table.addColumnSortHandler(columnSortHandler);
When sorting column contains iPhone 1, iPhone 2, iPhone 3... then it sorts correctly ie, iPhone 1, iPhone 2, iPhone 3 for ascending & iPhone 3, iPhone 2, iPhone 1 for decending
But when sorting column contains:
1.92 MP
3.15 MP AF 0.31 MP
3.2 MP
5 MP AF and flash
1.3 MP
1.3 MP
2 MP (rear); 0.3 MP (front)
1.92 MP AF with flash (rear)
it follows no correct order, it didn't even put the 2 "1.3 MP" cell next to each other. The correct order for the above list should be:
1.3 MP
1.3 MP
1.92 MP
1.92 MP AF with flash (rear)
2 MP (rear); 0.3 MP (front)
3.15 MP AF 0.31 MP
3.2 MP
5 MP AF and flash
Is there anything wrong with the code above?