В Swift говорят, что у меня есть два массива:
var array1: [Double] = [1.2, 2.4, 20.0, 10.9, 1.5]
var array2: [Int] = [1, 0, 2, 0, 3]
Теперь, я хочу сортировать массив1 в порядке возрастания и reindex array2 соответственно, чтобы получить
array1 = [1.2, 1.5, 2.4, 10.9, 20.4]
array2 = [1, 3, 0, 0, 2]
Есть ли простой способ сделать это с помощью функций Swift или синтаксиса?
Я знаю, что могу построить функцию, чтобы сделать это, и отслеживать индексы, но мне любопытно, есть ли более элегантное решение.