Sorting an ArrayList that contains custom objects

Source: http://stackoverflow.com/questions/10853205/android-sort-arraylist-by-properties

You need to implement a Comparator for instance:

public class FishNameComparator implements Comparator<Fish>
{
    public int compare(Fish left, Fish right) {
        return left.name.compareTo(right.name);
    }
}

and then sort it like this:

Collections.sort(fishes, new FishNameComparator());