I have an arrayList “listItems” with multiple objects, each having an “Item Name” and “Item Price”.
I create a custom base adapter “adapterItems” and in my activity I set the adapter to the list
AdapterItems adapterItems = new AdapterItems(MyActivity.this, listItems);
listView.setAdapter(adapterItems);
Everything works fine and all the items are displated in my activity as a list view in the order the objects were added to the arrayList.
Now I want to sort this list by ascending order of item price.
I am ok to sort the listItems first before giving it to the adapter OR sort the listview adapter later on. How can I do either/both?
Use Comparable to sort your listview.
See this Example That compare name and sort it in Alphabetical order
in your case::
And