title: How to sort response by header date in cellForRowAt function in uitableview
body: <p>I currently have a json response from <a href="https://api.myjson.com/bins/16g176" rel="nofollow noreferrer">json</a> which is a [NSDictionary]. This is displayed in a tableview and I was able to set the sorted dates into headers however I am having a difficulties in setting the uilabel in the cellForRowAt function. The tableview I was looking to display has a header title of sorted dates(which I already have) and under the section are the names with the same date as the header. I have provided the code for this below. Thank you for your help and suggestions. </p>
  
  <pre><code>import UIKit
  import Alamofire
  
  class JSONTableViewController: UITableViewController 
  
  {
  
  var responseValue:[NSDictionary] = []
  var sortedResponsevalue:[NSDictionary] = []
  var sectionHeaderArray:[String] = []
  var rowTitle:[String] = []
  
  override func viewDidLoad() {
      super.viewDidLoad()
  }
  
  override func viewWillAppear(_ animated: Bool) {
      super.viewWillAppear(animated)
      for response in self.responseValue {
          let dateFormatter = DateFormatter()
          dateFormatter.dateFormat = "yyyy-MM-dd"
          let responseDate = response.object(forKey: "date") as! String
          let date = dateFormatter.date(from: responseDate)
          print(date!.toString(dateFormat: "MMM d, yyyy"))
          self.sectionHeaderArray.append(date!.toString(dateFormat: "MMM d, yyyy"))
          self.rowTitle.append(response.object(forKey: "name") as! String)
      }
      print(self.sectionHeaderArray.count)
  }
  
  override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -&gt; String? {
      return self.sectionHeaderArray[section]
  }
  
  // MARK: - Table view data source
  
  override func numberOfSections(in tableView: UITableView) -&gt; Int {
      // #warning Incomplete implementation, return the number of sections
      return self.sectionHeaderArray.count
  }
  
  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return self.sectionHeaderArray[section].count
  }
  
  override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat {
      return 80
  }
  
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: "jsonCell", for: indexPath) as! JSONTableViewCell
  
      if let nameString = self.responseValue[indexPath.row].object(forKey: "name") as? String {
          cell.jsonLabel.text = nameString
  
      }
  
  
        return cell
      }
  }
  </code></pre>