title: How to set Alphabetical sections in UITableview
body: <p>I'm stuck at this point, where I want to set alphabetical section with the right cells in them. So far I have been able to add section from "a" to "z", but all my cells get listed under all sections. I can't come up with a soution which sorted the cells under the right section. Hope you guys can help - thank you.</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>var PersonName: [String?]? = []
  var PersonNumber : [Array&lt;String?&gt;?]? = []
  var Dic:[String:String?]? = [String:String?]?()
  
  let sections:Array&lt;String&gt; = ["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"]
  
  func sectionIndexTitlesForTableView(tableView: UITableView) -&gt; [String]? {
          return self.sections
      }
  
      func tableView(tableView: UITableView,
          sectionForSectionIndexTitle title: String,
          atIndex index: Int) -&gt; Int{
  
              return index
      }
  
      func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int{
  
          return sections.count
      }
  
      func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return (PersonName?.count)!
      }
  
      func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
          let cell:UITableViewCell = UITableViewCell(style: .Subtitle, reuseIdentifier: "Cell")
  
          cell.textLabel?.text = PersonName![indexPath.row]!
          cell.detailTextLabel?.text = PersonNumber![indexPath.row]!.first!
  
          return cell
  
      }
  
      func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
          let indexPath = tableView.indexPathForSelectedRow!
  
          let currentCell = tableView.cellForRowAtIndexPath(indexPath)! as UITableViewCell
  
      }
  
  
      func tableView(tableView: UITableView,
          titleForHeaderInSection section: Int) -&gt; String?{
  
              return self.sections[section]
      }
  </code></pre>