I am sorting JSONArray and show them in a custom list view, but after sorting the data does not changed in custom list view.
Here is my code for fab button to select
In my case i got homeList(ArrayList of model 'Home') from JSONParser class so befor setAdapter
Collections.sort(homeList, new Comparator() {
public int compare(Home emp1, Home emp2) {
int price1 = emp1.getPrice();
int price2 = emp2.getPrice();
return Integer.compare(price1, price2);
}
});
Adapter adapter = new Adapter(getActivity(),homeList);
listView.setadapter(adapter);
So this will first sort whole arraylist and then we need to setAdapter.
Try this i think this will help you.