i forgot to tell , the columns were iritated in a loop. ListHandler<List<String>> columnSortHandler = new ListHandler<List<String>>( list); for (int k=0; k<10; k++){ IndexedColumn myColumn=new IndexedColumn(k+1); table.addColumn(myColumn, "col "+k); myColumn.setSortable(true); columnSortHandler.setComparator(myColumn, new Comparator<List<String>>() { public int compare(List<String> o1, List<String> o2) {
return o1.get(0).compareTo(o2.get(0)); } }); } When I do the sorting, the sorting action was invoked, the table did the sorting but the orders of values in that column is not correct. So I suspect it could be I put the columnSortHandler.setComparator inside a loop & that causing the problem. How to fix it? On Monday, April 22, 2013 10:17:12 PM UTC+10, PhiLho wrote: > > On 22/04/2013 12:42, Tom wrote: > > Your code didn't work, beside it got the problem for non-digit string. > Ex: if i sort this > > Which one? The numerical comparison was shown only to illustrate how to do > a non-trivial sort. > The first one was to show you complicated too much the comparison method, > it can be much > simpler. > Note that your method as well as mine only sort the first column of the > table. > As shown in the second method, if you plan to sort another column, you > have to provide its > index to get the data at the proper place. > > -- > Philippe Lhoste > -- (near) Paris -- France > -- http://Phi.Lho.free.fr > -- -- -- -- -- -- -- -- -- -- -- -- -- -- > > -- 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 google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. 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.