I try to sort my table view content with creation date. The newest should be above. My code seems ok but it does not show the correct order. It is the opposite.
ref = Database.database().reference().child("placeID/\(placeIdFromSearch)")
ref.queryOrdered(byChild: "userTime").queryLimited(toLast: 10).observe(DataEventType.value, with: {(snapshot) in
if snapshot.childrenCount > 0 {
self.table.removeAll()
for video in snapshot.children.allObjects as! [DataSnapshot] {
let Object = video.value as? [String: AnyObject]
let userName = Object?["userName"]
let userGroup = Object?["userGroup"]
let userComment = Object?["userComment"]
let userTime = Object?["userTime"]
let userLikes = Object?["userLikes"]
let video = Videos(userName: userName as! String, userGroup: userGroup as! String, userComment: userComment as! String, userTime: userTime as! Int, userLikes: userLikes as! String)
self.table.append(video)
self.tableView.reloadData()
}
}
})