title: Sorting Database list android by likes
body: <p>I am building recipes app. I have page in my app that retrieves all the recipes from the database on Firebase into ListView. Each Recipe has these variables:</p>
  
  <pre><code>public String key;
  public String uid;
  public String title;
  public String type;
  public String ingredients;
  public String instructions;
  public int likes;
  </code></pre>
  
  <p>Here's the function that retrieves all the data :</p>
  
  <pre><code>//Retrieve Data from database
  public void retriveData() {
      database.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              recipes = new ArrayList&lt;Recipe&gt;();
              for(DataSnapshot data : dataSnapshot.getChildren()) {
                  Recipe r = data.getValue(Recipe.class);
                  recipes.add(r);
              }
              allRecipeAdapter = new AllRecipeAdapter(AllRecipeActivity.this,0,0,recipes);
              lv.setAdapter(allRecipeAdapter);
          }
       }
   }
  </code></pre>
  
  <p>Now i want to create another screen that also has a ListView and i would like to sort the Recipes by nubmer of likes and then enter the top 10 recipes into the ListView.
  I searched on Google i found the function OrderByValue but i can't figure out how to use it i realized how to works but i can't implement this to my project.</p>