using System.Collections.Generic;
using System.Linq;
using System;
public static class Utilities
{
public static IEnumerable Mode(this IEnumerable values)
{
var grouped = values
.GroupBy(x => x)
.OrderByDescending(x => x.Count())
.Select(x => new { Count = x.Count(), Value = x.Key });
var modes = grouped
.Where(x => x.Count == grouped.First().Count)
.Select(x => x.Value);
return modes;
}
}