1

My RecyclerView by defaults shows items sorted by name (that's how they come out of the database). I'am offering 4 additional sort options in the action bar for the users. I'm thinking of having 5 lists in the RecyclerView one for each sort and another list (just a reference) to point to the current list. When new data arrives the lists get sorted appropriately and when the user selects a sort order the current list gets the appropriate value and I call notifyDataSetChaged(). Is this a reasonable approach?

dfasdflskladf
  • 101
  • 1
  • 6

1 Answers1

0

You don't need to have multiple lists one list is enough. You just have to order it as you want then replace it in your adapter then call notifyDataSetChanged() To sort your data you can use Comparator like in here : How to sort an ArrayList in Java Hope it helps

Master Fathi
  • 349
  • 1
  • 9
  • 19