0

I have a problem to solve in my Android app. I currently retrieve from the Firebase Realtime Database a list of users to be displayed, these users having name and nickname. The name field is required and will always exist in the database, but the nickname is optional and may not exist. I need to display in alphabetical order so that the list is sorted by nickname and if it does not exist the name will be displayed, both ordered in the recyclerView. I have already made the filter to display the nickname in the list item if it exists, if it does not exist it will display the name, but I need to sort this list in the way I have described. For example:

Users
  |-id1
     |-name: "John Lande"
     |-nickname: "Potato"
  |-id2
     |-name: "Ingrid Cage"
  |-id3
     |-name: "Anny Baratheon"
     |-nickname: "Noisy"

And it should be displayed in the list like this:

- List
    |- Ingrid Cage
    |- Noisy
    |- Potato

Remembering that the display of the names I have already resolved, but the ordination that I do not know how to do. In the firebase documentation I have already seen that ordering through the "orderByChild" should only be done for one value per query.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Thomas Marques
  • 981
  • 2
  • 7
  • 16

0 Answers0