I wrote a really simple bubble sort for a card game. It takes an array of \"Card\" objects, each of which has a an \"order\" attribute which indicates the value to be sorted
Function parameters are by default constant (as if declared with let).
If you want to modify the parameter inside your function, you have to declare it as a variable:
func sortCards(var cards: Array) -> Array { ...
Note that only the local parameter cards is modified, not the array passed as
an argument to the function (which seems to be your intention because the function
returns a new array).