Someone from other forum solved it. So simple!
public int compare(List<String> o1, List<String> o2) {
if (o1 == o2) {
return 0;
}
// Compare the column.
if (o1 != null) {
int index = verbColumn.getIndex();
return (o2 != null) ?
o1.get(index).compareTo(o2.get(index)) : 1;
}
return -1;
}
But thax you all you guy anyway.
On Monday, April 22, 2013 6:44:32 PM UTC+10, Tom wrote:
>
> 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?
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.