     }
     
     @IBAction func filterSelected(_ sender: AnyObject) {
-        let filterMenu = UIAlertController(title: nil, message: "Choose Filter Type", preferredStyle: .actionSheet)
-
-        for facet in searchFacets {
-            
-            let facetAction = UIAlertAction(title: facet.key, style: .default, handler: {
-                (alert: UIAlertAction!) -> Void in
-                self.showSubFilter(withFacets: facet.value)
-            })
-            filterMenu.addAction(facetAction)
+        
+        let titles = searchFacets.map({ $0.key })
+        
+        let alertController = UIAlertController.createFacetActionSheet(withTitle: titles) { index in
+            guard let facetSelected = self.searchFacets[titles[index]] else {
+                return
+            }
+            self.showSubFilter(withFacets: facetSelected)
         }
         
         if currentFilter != nil {

import UIKit

private let reuseIdentifier = "productCell"

enum SortingOptions: String {
    case priceLowest = "Price Low to High"

                self.currentFilter = nil
                self.searchForProducts()
            })
            alertController.addAction(removeFilterAction)
        }
        self.present(alertController, animated: true, completion: nil)
    }
    
    func showSubFilter(withFacets facets: [RCHSearchFacet]) {
        
        let titles = facets.map( { $0.title })
        
        let alertController = UIAlertController.createFacetActionSheet(withTitle: titles) { index in
            let facetSelected = facets[index]
            self.currentFilter = facetSelected
            self.searchForProducts()
        }
        self.present(alertController, animated: true, completion: nil)
    }
    
    @IBAction func sortPickerDoneSelected(_ sender: AnyObject) {
