Sort the list of two values using the firebase realtime database
up vote
0
down vote
favorite
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.
android firebase firebase-realtime-database
add a comment |
up vote
0
down vote
favorite
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.
android firebase firebase-realtime-database
Unless you have to filter by the name/nickname, can you just do the sorting outside of firebase?
– Mathew Berg
Jul 4 '17 at 15:09
Take a look at my answer - stackoverflow.com/a/44892176/7626492
– Rohan Stark
Jul 4 '17 at 16:01
I think at the moment there is no impediment to doing on the client side, however how could I do? I own the arraylist that is passed to the recyclerView adapter.
– Thomas Marques
Jul 4 '17 at 18:27
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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.
android firebase firebase-realtime-database
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.
android firebase firebase-realtime-database
android firebase firebase-realtime-database
edited Nov 11 at 7:01
Cœur
17.1k9102140
17.1k9102140
asked Jul 4 '17 at 14:42
Thomas Marques
627
627
Unless you have to filter by the name/nickname, can you just do the sorting outside of firebase?
– Mathew Berg
Jul 4 '17 at 15:09
Take a look at my answer - stackoverflow.com/a/44892176/7626492
– Rohan Stark
Jul 4 '17 at 16:01
I think at the moment there is no impediment to doing on the client side, however how could I do? I own the arraylist that is passed to the recyclerView adapter.
– Thomas Marques
Jul 4 '17 at 18:27
add a comment |
Unless you have to filter by the name/nickname, can you just do the sorting outside of firebase?
– Mathew Berg
Jul 4 '17 at 15:09
Take a look at my answer - stackoverflow.com/a/44892176/7626492
– Rohan Stark
Jul 4 '17 at 16:01
I think at the moment there is no impediment to doing on the client side, however how could I do? I own the arraylist that is passed to the recyclerView adapter.
– Thomas Marques
Jul 4 '17 at 18:27
Unless you have to filter by the name/nickname, can you just do the sorting outside of firebase?
– Mathew Berg
Jul 4 '17 at 15:09
Unless you have to filter by the name/nickname, can you just do the sorting outside of firebase?
– Mathew Berg
Jul 4 '17 at 15:09
Take a look at my answer - stackoverflow.com/a/44892176/7626492
– Rohan Stark
Jul 4 '17 at 16:01
Take a look at my answer - stackoverflow.com/a/44892176/7626492
– Rohan Stark
Jul 4 '17 at 16:01
I think at the moment there is no impediment to doing on the client side, however how could I do? I own the arraylist that is passed to the recyclerView adapter.
– Thomas Marques
Jul 4 '17 at 18:27
I think at the moment there is no impediment to doing on the client side, however how could I do? I own the arraylist that is passed to the recyclerView adapter.
– Thomas Marques
Jul 4 '17 at 18:27
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44908837%2fsort-the-list-of-two-values-using-the-firebase-realtime-database%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Unless you have to filter by the name/nickname, can you just do the sorting outside of firebase?
– Mathew Berg
Jul 4 '17 at 15:09
Take a look at my answer - stackoverflow.com/a/44892176/7626492
– Rohan Stark
Jul 4 '17 at 16:01
I think at the moment there is no impediment to doing on the client side, however how could I do? I own the arraylist that is passed to the recyclerView adapter.
– Thomas Marques
Jul 4 '17 at 18:27