у меня
места, которые содержат это содержимое
print(places)
Optional(Results<Place> <0x109526f30> (
[0] Place {
name = 127 Pine St;
country = United States;
lat = 42.63341130000001;
lon = -71.33169049999999;
},
[1] Place {
name = 138 B St;
country = United States;
lat = 42.6285025;
lon = -71.3288776;
},
[2] Place {
name = 16 Bagley Ave;
country = United States;
lat = 42.6344084;
lon = -71.3378318;
},
[3] Place {
name = 27 Lane St;
country = United States;
lat = 42.6346452;
lon = -71.32436559999999;
},
[4] Place {
name = 39 Cosgrove St;
country = United States;
lat = 42.61964890000001;
lon = -71.3031683;
},
[5] Place {
name = 48 Houghton St;
country = United States;
lat = 42.6252232;
lon = -71.3243308;
},
[6] Place {
name = 49 Coral St;
country = United States;
lat = 42.6359846;
lon = -71.32655780000002;
},
[7] Place {
name = 59 Marriner St;
country = United States;
lat = 42.622121;
lon = -71.31365679999999;
}
)) <<<
У меня также есть другой массив, который я храню в памяти, который выглядит следующим образом
print(distances)
["1.74", "1.45", "2.04", "1.50", "0.00", "1.15", "1.64", "0.56"]
Результат
Мой конечный результат выглядит следующим образом.
![enter image description here](https://i.stack.imgur.com/R8PqK.png)
код
Вот как я отображаю эту таблицу
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "customPlaceDetailCell", for: indexPath)
as! CustomPlaceDetailCell
if selectedPlace.name != nil {
cell.address.text = (places![indexPath.row]["name"] as! String)
cell.distance.text = distances[indexPath.row]
if indexPath.row == activePlace {
cell.address.isHidden = true
cell.distance.isHidden = true
}
}
return cell
}
хочу
чтобы показать мой результат, отсортированный по расстоянию ближе к дальнейшему
Примечание: мое расстояние не является частью моего места. Я рассчитал их во время выполнения.
Как бы один и пошел и сделать это?