How can I change the order of two arrays when one array is sorted?

4 months ago by
If I have:
var arrayOne = ["dog", "cat", "hamster", "horse"]​


var arrayTwo = [3, 2, 4, 1]

How can I assign 3 to dog, 2 to cat, 4 to hamster, and 1 to horse so that if I sort arrayTwo from biggest integer to smallest, it will automatically do that for arrayOne too. In result it would print out:

var arrayOne = ["hamster", "dog", "cat", "horse"]
var arrayTwo = [4, 3, 2, 1]

What code is easiest and simplest for this?

Thanks in Advance! :)

Community: Swift
Please login to add an answer/comment or follow this question.

Similar posts:
Search »
  • Nothing matches yet.