What is the best practice of sorting this table in Swift 4?
A-Z
override func viewDidLoad() {
super.viewDidLoad()
list = [ ghost(name:"alphabet".localized, id:"1"),
ghost(name:"élephant".localized, id:"2"),
ghost(name:"delegate".localized, id:"3")]
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if filtering() {
return filter.count
}
return list.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "library", for: indexPath)
var data: ghost
if filtering() {
data = filter[indexPath.row]
}
else {
data = list[indexPath.row]
}
cell.textLabel!.text = data.name
return cell
}
I am using translated strings a lot. So it would be nice, if the table can be loaded alphabetically in different language. Can someone help me with that? I searched the whole internet and just got too exhausted of this... Thanks a lot!