Skip to content

Instantly share code, notes, and snippets.

@semuserable
Created July 25, 2017 21:04
Show Gist options
  • Save semuserable/82b45b3ba1c20853048bc19a0647709d to your computer and use it in GitHub Desktop.
Save semuserable/82b45b3ba1c20853048bc19a0647709d to your computer and use it in GitHub Desktop.
let data = [
("January", 1);
("June", 10);
("March", 12);
("February", 20);
("January", 15);
("July", 15)
]
let grouped =
data
|> List.groupBy fst
|> List.map (fun (key, group) -> key, group |> List.sumBy snd)
|> List.map (fun (month, total) -> DateTime.ParseExact(month, "MMMM", CultureInfo.InvariantCulture), total)
|> List.sortBy (fun (month, _) -> month.Month)
|> List.map (fun (month, total) -> month.ToString("MMMM"), total)
|> Dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment