LeetCode 905. Sort Array By Parity in F#

URL

leetcode.com/problems/sort-array-by-parity

Code

github.com/syohex/dotnet-study/blob/master/..

let sortArrayByParity (nums: int list) : int list =
    nums
    |> List.sortWith (fun a b ->
        match a &&& 1, b &&& 1 with
        | 0, 0 -> compare a b
        | 0, 1 -> -1
        | 1, 0 -> 1
        | _, _ -> compare a b)