title: Swift - sortTable shall update view immediately
body: <p>I'm new to Swift, hence I'm open for any suggestion related to my code, since I have concerns about the efficiency of the app. </p>
  
  <p>My intention is to update the view, everytime a action is called. - I've got a TableView inside of my ViewController and I want the user to be able to sort the table asc or desc on click. </p>
  
  <p>Theoretically the code works and the user is able to click the given button which changes <code>isAsc</code>. But I haven't been able to update the view instantly after the button was clicked. So far, it only updates when I leave the ViewController and come back from another by <code>preformSegue</code>. </p>
  
  <pre><code>    let defaults = UserDefaults.standard
  
      var isAsc = true
  
      var gefahreneKm: [String] = []
      var date: [String] = []
      var consumedLiters: [String] = []
      var pricePerLiter: [String] = []
  
      override func viewDidLoad() {
          super.viewDidLoad()
          isAsc = defaults.bool(forKey: "isAsc")
          gefahreneKm = createArray()
          date = createArrayDate()
          consumedLiters = createArrayConsumedL()
          pricePerLiter = createArrayPricePerLitre()
          self.toolbar.setBackgroundImage(UIImage(),
                                          forToolbarPosition: .any,
                                          barMetrics: .default)
          self.toolbar.setShadowImage(UIImage(), forToolbarPosition: .any)
          timlineView.delegate = self
          timlineView.dataSource = self 
      }
  
      func createArray() -&gt; [String] {
          let arrayDrivenKmString = arrayDrivenKm.map{ String($0) }
  
          if isAsc == true {
              return arrayDrivenKmString
          } else {
              return arrayDrivenKmString.reversed()
          }
      }
  
      func createArrayDate() -&gt; [String] {
          if isAsc == true {
              return arrayDate
          } else {
              return arrayDate.reversed()
          }
      }
  
      func createArrayConsumedL() -&gt; [String] {
          if isAsc == true {
              return arrayConsumedL
          } else {
              return arrayConsumedL.reversed()
          }
      }
  
      func createArrayPricePerLitre() -&gt; [String] {
          if isAsc == true {
              return arrayPricePerLiter
          } else {
              return arrayPricePerLiter.reversed()
          }
      }
  
      @IBAction func buttonBack(_ sender: Any) {
          performSegue(withIdentifier: "goBackToMain", sender: self)
      }
  
      @IBAction func sortTable(_ sender: Any) {
          isAsc = !isAsc
          defaults.set(isAsc, forKey: "isAsc")
      }
  </code></pre>