なぜコードのデータを子供の値「scoreTotal」でソートするとは思わないのですか?私は値scoreTotalでソートしようとしましたが、子 "scoreTotal"によってクエリを実行しましたが、それはまだセルタイトルのアルファベット順にテーブルビューに表示されています。テーブルビューのFirebaseデータを子供の値で注文する
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CellMale", for: indexPath as IndexPath)
let comp = comps[indexPath.row]
let dbRef1 = FIRDatabase.database().reference().child("Live Scoring Male/\(String(describing: comp.name!))/scoreTotal")
dbRef1.queryOrdered(byChild: "scoreTotal").observe(FIRDataEventType.value, with: { (snapshot) in
let scoreTotal = snapshot.value as! Double
cell.detailTextLabel?.text = String(scoreTotal)
self.comps.sorted(by: {$0.scoreTotal > $1.scoreTotal})
})
cell.textLabel?.text = comp.name
return cell
}