Clean Swift Solution
Introduction\nThis problem uses a very similar technique to move zeros.\n\nExplanation\nNote the line var A = A. Since arrays are value types in Swift we cannot
**Introduction**\nThis problem uses a very similar technique to [move zeros](https://leetcode.com/problems/move-zeroes/).\n\n**Explanation**\nNote the line `var A = A`. Since arrays are value types in Swift we cannot modify the array without making a copy. If you saw this problem in an interview, it would be good to mention that we could improve the peformance by using `inout [Int]` as the parameter type since this would allow us to modify the array in place. \n\nThe `lastEven` variable will always point to the next available index for an even number. If we swap all the even numbers with `lastEven` then all the even numbers will be moved to the front of the array. At the sime time the odd numbers will be moved to the end of the array. \n\n**Solution**\n```\nclass Solution {\n    func sortArrayByParity(_ A: [Int]) -> [Int] {\n        var A = A\n        var lastEven = 0 \n        for i in 0 ..< A.count {\n            if A[i] % 2 == 0 {\n                A.swapAt(i, lastEven)\n                lastEven += 1\n            }\n        }\n        return A\n    }\n}\n```
[]