title: How to get messages ordered by timestamp
body: <p>i want to get all messages by their creation date (which is timestamp).</p>
  
  <p>My data structure looks like this:</p>
  
  <pre><code>messages
    XRJONcahNUgeNrfkH3cmITJt3409 (auto uid of owner - user)
      -KoOSxA2Iajk3kv20U_p (automatic uid generated by Firebase)
        message: "Hi"
        senderId: "X8Oxg5J9Imb12C1iYBXJT9P48909"
        senderName: "Dave"
        timestamp: 1505813320526 (automatic timestamp)
      -GdOSxR2Iajk3kv20U_p --- I NEED TO SORT THESE UIDS
        message: "Hello"
        senderId: "G7Oxg5J9Imb12C1iYBXJT9P48909"
        senderName: "Frank"
        timestamp: 1505813321024 (automatic timestamp)
  </code></pre>
  
  <p>And I get all messages like this:</p>
  
  <pre><code>database.child("messages").child(ownersId).observeSingleEvent(of: .value, with: { (snapshot) in
              print(snapshot)
              if let messagesDict = snapshot.value as? [String:AnyObject] {
                  for (_,message) in messagesDict {
                      self.messages.append((message["message"] as? String)!)
                      self.users.append((message["senderName"] as? String)!)
                      self.timestamps.append((message["timestamp"] as? IntMax)!)
                  }
              }
              completionHandler(true)
  
          }) { (error) in
              print(error.localizedDescription)
              completionHandler(false)
          }
  </code></pre>
  
  <p>So the question is, how can I get all messages ordered from the oldest to the newest? I dont know how can I use ordering methods (queryOrderedByKey(), queryOrderedByValue() or queryOrdered(byChild: "timestamp") in this specific case. Firebase sends me data in random order (I dont know if it is random, but it is not sorted by date).</p>