001package horstmann.ch04_sort2;
002import java.util.ArrayList;
003import java.util.Collections;
004import java.util.Comparator;
005
006public class ComparatorTester
007{
008        public static void main(String[] args)
009        {
010                ArrayList<Country> countries = new ArrayList<Country>();
011                countries.add(new Country("Uruguay", 176220));
012                countries.add(new Country("Thailand", 514000));
013                countries.add(new Country("Belgium", 30510));
014                Comparator<Country>  comp = new CountryComparatorByName();
015                Collections.sort(countries, comp);
016                // Now the array list is sorted by area
017                for (Country c : countries)
018                        System.out.println(c.getName() + " " + c.getArea());
019        }
020}
021