1 //Linq 2 3 //var result = from p in personList 4 // group p by p.Id 5 // into grouped 6 // select new { Id = grouped.Key, Count = grouped.Count() } 7 // into temp 8 // orderby temp.Count descending 9 // select temp; 10 11 12 13 //Lambda 14 15 var result = 16 personList.GroupBy(g => g.Id) 17 .Select(s => new { Id = s.Key, Count = s.Count() }) 18 .OrderByDescending(o => o.Count);