Reputation: 139
I am using Comparator
to sort my ListView
, but it doesn't work.
My code:
Collections.sort(orgi, new Comparator<Loc>() {
@Override
public int compare(Loc lhs, Loc rhs) {
if( lhs.getDist() < rhs.getDist() )
return 1;
else
return 0;
}
});
Can anyone suggest a solution?
Upvotes: 0
Views: 176
Reputation: 17284
Try this:
Collections.sort(orgi, new Comparator<Loc>() {
@Override
public int compare(Loc lhs, Loc rhs) {
if(lhs.getDist() < rhs.getDist()){
return -1;
} else if(lhs.getDist() > rhs.getDist()){
return 1;
} else {
return 0;
}
}
});
Upvotes: 3