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.










share|improve this question
























  • 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

















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.










share|improve this question
























  • 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















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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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




















  • 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



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues