In lines 5 to 8, there is an
anonymous inner class that implements Comparator<
String>.
Line 6 is the start of the compare method of the Comparator.
In line 7, the two strings are compared by looking at the first character of each string and subtracting the two char values. This gives a value, which is returned as an int (positive, zero or negative), which determines the sort order. Lookup the API documentation of String.charAt(...).
In line 9, the comparator 'best' is used to sort the string array 'words'.