I am trying to sort the category arraylist with Collections.sort
method but have no luck with it.
Here is my code:
public class Categories i
Collections.sort(yourListHere,new Comparator<Categories>() {
@Override
public int compare(Categories lhs, Categories rhs) {
//your sort logic here
return 0;
}
});
Hope this helps.
You can also use custom comparator:
public class CategoriesComparator implements Comparator<Category> {
@Override
public int compare(Category category1, Category category2) {
return category1.getSomeProperty().compareTo(category2.getSomeProperty());
}
}
When you want to compare call this:
Collections.sort(yourListCategories, new CategoriesComparator());
Hope it helps!