Kotlin solution
\nclass Solution {\n    fun sortArrayByParityII(A: IntArray): IntArray {\n        val even = A.filter { it % 2 == 0 }\n        val odd = A.filter { it % 2 == 1 
```\nclass Solution {\n    fun sortArrayByParityII(A: IntArray): IntArray {\n        val even = A.filter { it % 2 == 0 }\n        val odd = A.filter { it % 2 == 1 }\n        return even.zip(odd).flatMap { listOf(it.first, it.second) }.toIntArray()\n    }\n}\n```
[]