   }
 
   func sectionIndexTitles(for tableView: UITableView) -> [String]? {
-    return ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
-            "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "#"]
+    return dataSource.sortedFriends.keys.sorted()
   }
 }
 
 extension FriendPickerViewController : UITableViewDelegate {
+  func numberOfSections(in tableView: UITableView) -> Int {
+    return dataSource.sortedFriends.keys.count
+  }
+
+  func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
+    return dataSource.sortedFriends.keys.sorted()[section]
+  }
+
   func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int)
       -> Int {
-    return dataSource.cells.count
+    let key = dataSource.sortedFriends.keys.sorted()[section]
+    return (dataSource.sortedFriends[key]?.count)!
   }
 
   func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell,
                  forRowAt indexPath: IndexPath) {
-    let cellInfo = dataSource.cells[safe: indexPath.row] as! FriendCellInfo
+    let key = dataSource.sortedFriends.keys.sorted()[safe: indexPath.section]
+    let contacts = dataSource.sortedFriends[key!]
+    let contact = contacts?[safe: indexPath.row]
+    let cellInfo = dataSource.cells.filter { (ci) in
+      return (ci as! FriendCellInfo).fbid == contact
+    }.first! as! FriendCellInfo
     cell.accessoryType =
         dataSource.selectedFriends.contains(cellInfo.fbid) ? .checkmark : .none
   }

  var cells = [CellInfo]()

  var selectedFriends = [String]()

  func reload(completion: @escaping () -> Void) {
    if cells.isEmpty {

    }
  }

  private func configureNavigationBar() {
    navigationItem.title = "Select Friends"
    navigationItem.leftBarButtonItem =
        UIBarButtonItem(barButtonSystemItem: .cancel, target: self,
                        action: #selector(cancelTapped))
    navigationItem.rightBarButtonItem =
        UIBarButtonItem(barButtonSystemItem: .done, target: self,
                        action: #selector(doneTapped))
  }

  private func configureTableView() {
    // TODO(compnerd) create a constant for this value
    tableView.rowHeight = 40.0
    tableView.separatorStyle = .none
    tableView.delegate = self
    tableView.dataSource = self
