別々の配列のままでソートしたいなら、いったん index の配列をソートして、それに基づいて member と score を並べ替える方法があります。
swift
1var member = ["A","B","C","D","E"]
2var score = [2,4,1,0,3]
3
4let index = score.indices.sorted { score[$0] > score[$1] }
5member = index.map { member[$0] }
6score = index.map { score[$0] }
7
8print(member) // ["B", "E", "A", "C", "D"]
9print(score) // [4, 3, 2, 1, 0]
が、タプルや構造体の配列を使った方が分かりやすいかと思います。
swift
1var tuples = [("A", 2), ("B", 4), ("C", 1), ("D", 0), ("E", 3)]
2tuples.sort { $0.1 > $1.1 }
3print(tuples) // [("B", 4), ("E", 3), ("A", 2), ("C", 1), ("D", 0)]
swift
1struct Member {
2 var name: String
3 var score: Int
4}
5
6var members = [
7 Member(name: "A", score: 2),
8 Member(name: "B", score: 4),
9 Member(name: "C", score: 1),
10 Member(name: "D", score: 0),
11 Member(name: "E", score: 3),
12]
13
14members.sort { $0.score > $1.score }