import java.util.Arrays;
import java.util.Comparator;

class SortByComparator
{
	static class Item{
		String name;
		int birth;
		Item(String n, int b){
			name = n;
			birth = b;
		}
		public String toString(){
			return "["+name+", "+birth+"]";
		}
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Item chopin = new Item("Chopin", 1810);
		Item mozart = new Item("Mozart", 1756);
		Item beethoven = new Item("Beethoven", 1770);
		Item[] items = new Item[]{chopin, mozart, beethoven};
		
		Comparator<Item> c = new Comparator<Item>(){
			public int compare(Item a, Item b){
				return a.birth - b.birth;
			}
		};
		
		Arrays.sort(items, c);
		
		for(Item it:items)
			System.out.println(it);
	}
}