I want to order an array with the help of another, like this:
var names = [anna, berta, caesar, dora]
var sorting = [2, 0, 1, 3]
to be sorted like this:
var sortedNames = [caesar, anna, berta, dora]
so that the Integer array ("sorting") sorts the String array ("names") after its own values. How can I do that?
I tried it with a for loop, but it didn't worked.
for i in 0...names.count
{
let x = "\(names[sorting]])"
sortedNames.append(x)
}
return history