         }
         self.present(alertController, animated: true, completion: nil)
     }
-    
+
+    @IBAction func sortSelected(_ sender: AnyObject) {
+        pickerView.isHidden = false
+    }
+
     @IBAction func sortPickerDoneSelected(_ sender: AnyObject) {
         currentSort = SortingOptions.allValues[sortPicker.selectedRow(inComponent: 0)]
         searchForProducts()

        view.endEditing(true)
        autocompleteSuggestions.removeAll()
        sortButton.setTitle("Sort", for: .normal)
        if products.isEmpty {
            sortFilterView.isHidden = true
            searchProductsLabel.text = "Search Products"
            searchProductsImageView.image = UIImage(named: "img-search.pdf")
            searchProductsView.isHidden = false
        } else {
            sortFilterView.isHidden = false
        }
    }
    
    // MARK: API

    }
    
    func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
        searchTerm = searchText.replacingOccurrences(of: " ", with: "")
        timer?.invalidate()
        if !searchTerm.isEmpty {
            autocomplete(withQuery: searchText)
            timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(self.searchForProducts), userInfo: nil, repeats: false)
        }
    }
    
