import java.util.Arrays;
import java.util.Comparator;
class LastFirstComparator implements Comparator {
public int compare(Object obj1, Object obj2) {
int result = 0;
int i = 0;
String[] str1 = (String[]) obj1; /// this seems not working, how to change to string type?
String[] str2 = (String[]) obj2; /// because it is working with String array.
do {
result = str1[i].compareTo(str2[i]);
i++;
if (i == 7) {
break;
}
} while (result == 0);
return result;
}
}
public class LexiComparator {
public static void main(String args[]) {
Integer a1[][] = {{13, -2, 3, 99, 0, 9, 45},
{2, 3, 9, 45, 4, 44, 21},
{22, 445, 0, -5, -56, 6, 223}};
Arrays.sort(a1, new LastFirstComparator());
}
}