I have and object called Person that has props
string Name string Amount The amount is an integer but held as a string.
Each group is formed when the Amount is within n of each other.
i.e. if n=3
Jeff 20 Jack 19 Ben 16 Kyle 12 would be 3 groups Jeff 20 Jack 19 ---------- Ben 16 ---------- Kyle 12 ---------- I tried this but No grouping happens...
var ranges = new[] {3}; var grouped = orderByResult.GroupBy(x => ranges.FirstOrDefault(r => r > Convert.ToInt32(x.Amount)));