fork download
using System;
using System.Linq;
using System.Collections.Generic;

class Customer
        {
            public string ID { get; set; }
            public string Name { get; set; }
            public string Suburb { get; set; }
            public int Balance { get; set; }
            public int Year { get; set; }

            public Customer(string a, string b, string c, int balance, int year)
            {
                ID = a;
                Name = b;
                Suburb = c;
                Balance = balance;
                Year = year;
            }
        }

public class Test
{
	public static void Main()
	{
            var customers = new List();
            customers.Add(new Customer("C0020", "Alfred", "Campbelltown", 1500, 2006));
            customers.Add(new Customer("C0021", "Ryder", "Liverpool", 2000, 2008));
            customers.Add(new Customer("C0022", "Alison", "Strathfield", 5500, 2012));
            customers.Add(new Customer("C0023", "Eliza", "Liverpool", 6000, 2012));
            customers.Add(new Customer("C0024", "Natsu", "Campbelltown", 2560, 2011));

            var suburbGroups = customers
                .GroupBy(c => c.Suburb)
                .Select(g => new { Suburb = g.Key, Balance = g.Sum(c => c.Balance) })
 		.OrderByDescending(x => x.Balance);

            foreach (var grp in suburbGroups)
                Console.WriteLine("Suburb: {0}  Total-Balance: {1}", grp.Suburb, grp.Balance);
	}
}
Success #stdin #stdout 0.05s 37216KB
stdin
Standard input is empty
stdout
Suburb: Liverpool  Total-Balance: 8000
Suburb: Strathfield  Total-Balance: 5500
Suburb: Campbelltown  Total-Balance: 4060