class StringComparator implements Comparator { // Compare two Strings. Callback for sort. // effectively returns a-b; // e.g. +1 (or any +ve number) if a > b // 0 if a == b // -1 (or any -ve number) if a < b public final int compare ( Object a, Object b ) { return( (String)a ).compareTo( (String)b ); } // end compare } // end class StringComparator ... import java.util.Arrays; ... Arrays.sort( myArrayOfStringObjects, new StringComparator() );