/*************************************************************************************
 * Comparator classes for sorting
 * - This method sorts a fullname by the lastname part
 * - This method expect to receive two strings each being "firstname lastname"
 *
 ************************************************************************************/  
import java.util.*;

public class CompareLastname implements Comparator<String>
{ 
    public int compare(String s1, String s2) 
    {
        int start1 = s1.indexOf(" ")+1;		        //the character after the space
        int start2 = s2.indexOf(" ")+1;		        //the character after the space
	
        s1 = s1.substring(start1);			        //take the lastname
        s2 = s2.substring(start2);			        //take the lastname

        int value = s1.compareToIgnoreCase(s2);		//if s1 > s2  --> value = positive
                                                    //positive means flip the elements
        return (value);	
    }
}