LeetCode 1636. Sort Array by Increasing Frequency in F#
URL
Sort Array by Increasing Frequency - LeetCode
Code
let frequencySort (nums: int list) : int list =
let freq = nums |> List.countBy id |> Map.ofList
nums
|> List.sortWith (fun a b ->
match Map.find a freq, Map.find b freq with
| x, y when x = y -> compare b a
| x, y -> compare x y)