}
}
List<Country> countries = new ArrayList<Country>();
for (Map.Entry<String, Long> countryEntry : countryCounts.entrySet()) {
Country country = new Country();
country.setName(countryEntry.getKey());
country.setNumEvents(countryEntry.getValue().intValue());
countries.add(country);
}
// Sort the array on numEvents
for (int i = 1; i < countries.size(); i++) {
int numEvents = countries.get(i).getNumEvents();
int j = i - 1;
boolean done = false;
do {
if (countries.get(j).getNumEvents() < numEvents) {
Country swapped = countries.remove(j + 1);
countries.add(j, swapped);
j--;
if (j < 0) {
done = true;
}