I'm iterating data from children from Firebase Realtime Database [Click to view Data](https://i.stack.imgur.com/s2FhD.png), but for some reason the loops iterating order is not logical to me. 

Meaning that after checking the code below the log should show: 

**[XRA, 32-LY-14, 2, 1, 32-LY-15, 3, 2, YRa, 33-LY-77, 4, 3]**

but it shows:

**[XRA, YRa, 32-LY-14, 2, 1, 32-LY-15, 3, 2, 33-LY-77, 4, 3]**

Also if I put Log.d("TAG", DrawingsList.toString()); after finishing the DataSnapshot loops then Arraylist appears empty as if nothing is added to it.

```
 public void Drawings_71 () {
    DrawingsList.clear();
    FirebaseDatabase.getInstance().getReference().child("Drawings").child("Area 71").addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot ds : dataSnapshot.getChildren()) {
                TAG = ds.getKey();
                DrawingsList.add(TAG);
                FirebaseDatabase.getInstance().getReference().child("Drawings").child("Area 71").child(TAG).addListenerForSingleValueEvent(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot2) {
                        for (DataSnapshot ds2 : dataSnapshot2.getChildren()) {
                           String TAG2 = ds2.getKey();
                            String Current_Version = ds2.child("Current Version").getValue().toString();
                            String Previous_Version = ds2.child("Previous Version").getValue().toString();
                            DrawingsList.add(TAG2);
                            DrawingsList.add(Current_Version);
                            DrawingsList.add(Previous_Version);
                        }
                        Log.d("TAG", DrawingsList.toString());
                    }
                    @Override
                    public void onCancelled(DatabaseError databaseError) {
                    }
                });
            }
        }
        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
}

```