Sorting an ArrayList of Objects by Last name and firstname in Java
<p>I have an arrayList of different types of players based on sports.  I need to sort the list of players in the arrayList by last name to start.  If 2 players have the same last name it needs to then sort those 2 players by the first name.
example: Format Lastname firstname
Williams Robert
Phillips Warren
Doe John
Phillips Mark</p>

<p>Output should be 
Doe John
Phillips Mark
Phillips Warren
Williams Robert</p>

<p>What i have now only sorts by either the first or last i have it by last atm in my code.</p>

<pre><code>   public static void sortPlayers(ArrayList playerList) {
    for (int i = 0; i &lt; playerList.size(); i++) {
        for (int j = 0; j &lt; playerList.size(); j++) {
            Collections.sort(playerList, new Comparator() {

                public int compare(Object o1, Object o2) {
                    PlayerStats p1 = (PlayerStats) o1;
                    PlayerStats p2 = (PlayerStats) o2;
                    return p1.getPlayerLastName().compareToIgnoreCase(p2.getPlayerLastName());
                }
            });
        }

    }
}
</code></pre>
