title: Firebase - getting list of data in order (Last data first)
body: <p>I am working on a chat application. I want to get the last 20 messages from the Firebase database and in order, the message was added. 
  For example, if I have sent 3 different message "Hi", "What's up", "Bye". I should get "Hi", "What's up", "Bye" in the same order.</p>
  
  <p>The query I am using is following.</p>
  
  <pre><code>ref.child(Constants.messageListKey).child("-Laray524a9Na-C7zdij").queryLimited(toLast: Constants.messageLimitPerCall).observeSingleEvent(of: .value, with: { (snapshot) in 
         let currentUserChatList = snapshot.value as? NSDictionary
         if let chatList = currentUserChatList?.allKeys { 
           // parsing the data here
         }
  }
  </code></pre>
  
  <p>I even tried using <code>.queryOrderedByKey()</code> and <code>.queryOrdered(byChild:)</code> but still the same result.</p>
  
  <p>The result that I am getting is not in order. For example, I am getting "What's up", "Hi", "Bye". The result is not even ascending order nor descending order. It is just a random order.</p>
  
  <p>The scheme which I am using is like this:</p>
  
  <pre><code>-chatList
      -autogeneratedKey
           -msg = "Some Message"
  </code></pre>
  
  <p>Is there anything that I am missing?
  If there is any details that I have missed please let me know to understand my question better.</p>