I made a function that sorts an Array and reorders a TableView (I followed this post). I populate the array through an API.
When or where is best to call the sorting function? When I call it from ViewDidLoad or ViewDidAppear the Array is still empty, so nothing happens.
func sort(){
self.myArray = myArray.sorted(by: {$0.rank < $1.rank })
self.tableView.reloadData()
}