OrderByChild() not working in Android Client
<p>In my android application I am using following code</p>

<pre><code> FirebaseDatabase database = FirebaseDatabase.getInstance();

    ref = database.getReference().child(Keys.CONTACTIFY_CONTACTS).child(sharedPrefs.getString(SharedPreferenceValues.CURRENT_USER_UID, "")).child(Keys.SHARED_CONTACTS);
    refer = ref.orderByChild(Keys.TIME);
 refer.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                ArrayList&lt;HashMap&lt;String, Object&gt;&gt; sharedList = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;();
                if (dataSnapshot.getValue() != null) {
                    Object[] rootData = ((HashMap&lt;String, Object&gt;) dataSnapshot.getValue()).values().toArray();
                    for (Object singleElement :
                            rootData) {
                        HashMap&lt;String, Object&gt; eachElement = (HashMap&lt;String, Object&gt;) singleElement;
                        sharedList.add(eachElement);
                    }
                    recyclerView.setAdapter(new SharedItemsRecyclerViewAdapter(sharedList, mListener, getActivity()));
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
</code></pre>

<p>My firebase database structure is </p>

<p><a href="https://i.stack.imgur.com/wqboc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wqboc.png" alt="enter image description here"></a></p>

<p>My Firebase rules relevant to scenario are </p>

<pre><code>    {
  "rules": {
  "mapper":{
       ".read": "auth!= null",
         ".write": "auth!= null"
    },
      "share_id_mapper":{
       ".read": "auth!= null",
         ".write": "auth!= null"
    },
       "contactify_contacts":{
                       //can read a message if authenticated
                 "$uid": {
                    "shared_contacts": {".indexOn": "time",
                            ".write": "auth!= null",
</code></pre>

<p>Problem is that I am getting the hasmap from snapshot in default sorted way i.e. the sortbyKey(). But I am expecting the result based on the value of time key in the node data.</p>