Hi.. I have created a Comparator and I have a list. When I use the static method in Collections, called sort.. the sort works sometimes but on other occasions does not. That is it sorts as though 108 < 12 is true Can anyone explain why? Thanks SR
post your comparator code. Just from looking at your current results, it looks like it is comparing objects lexicographically ( like comparing Strings ) rather than as a number value. Jamie [ August 29, 2002: Message edited by: Jamie Robertson ]
Hi.. Thanks a lot to both of you. I did find the mistake. You see the Comparator was working fine, but like Jamie pointed out, the List had string objects in it. And in String comparisons, 108 < 12 is true. I rectified that by changing such objects to integer and it worked fine. Thanks a lot again. SR