       editButton.isHidden = false
     }
 
-    let query = Firestore.firestore().reviews.whereField("restaurantID",
-                                                         isEqualTo: restaurant.documentID)
+    let query = Firestore.firestore().reviews
+        .whereField("restaurantID", isEqualTo: restaurant.documentID)
+        .order(by: sort)
     localCollection = LocalCollection(query: query) { [unowned self] (changes) in
       if self.localCollection.count == 0 {
         self.tableView.backgroundView = self.backgroundView

let backgroundView = UIImageView()
let sortByOptions = ["date", "rating", "yumCount"]

  override func viewDidLoad() {
    super.viewDidLoad()


    
    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
       pickerView.isHidden = true
       sort = sortByOptions[row]
       self.viewWillAppear(true)
    }
}

