public ArrayList GetClientesFieis() { Dictionary <string, int> dict = new Dictionary <string, int>(); List <ClienteFiel> Lista = new List <ClienteFiel>(); _ListaHistorico.ForEach(h => { if (dict.ContainsKey(h.cliente)) { dict[h.cliente] += 1; } else { dict.Add(h.cliente, 1); } }); ArrayList arrlista = new ArrayList(); foreach (var item in dict) { ClienteFiel _ClienteFiel = new ClienteFiel(); _ClienteFiel.Nome = _ListaCliente.Where(c => c.id == Int32.Parse(item.Key)).FirstOrDefault().nome; _ClienteFiel.Total = item.Value; arrlista.Add(_ClienteFiel); } arrlista.Sort(new Comparer()); arrlista.Reverse(); return(arrlista); }
int IComparer.Compare(Object xx, Object yy) { ClienteFiel x = (ClienteFiel)xx; ClienteFiel y = (ClienteFiel)yy; //sort by age return(x.Total.CompareTo(y.Total)); }