Moving elements
Take a look at this mess! The players array contains names that start with A to F,
but they aren’t in the correct order, and that violates the rules of the game.
You can try to fix this situation by manually moving values one by one to their correct positions, like so:
let playerAnna = players.remove(at: 3) players.insert(playerAnna, at: 0) print(players)
// > ["Anna", "Donna", "Craig", "Brian", "Dan", "Eli", "Franklin"]
This works if you want to move a single element, but if you want to sort the entire array, you should use sort():
players.sort() print(players)
// > ["Anna", "Brian", "Craig", "Dan", "Donna", "Eli", "Franklin"]
If you’d like to leave the original array untouched and return a sorted copy instead, use sorted() instead of sort().