code: public static <T extends Comparable<T>> int compareLists(List<T> list1, List<T> list2) {
      if (list1 == null && list2 == null)
        return 0;
      if (list1 == null || list2 == null) {
        throw new IllegalArgumentException();
      }
      int size1 = list1.size();
      int size2 = list2.size();
      int size = Math.min(size1, size2);
      for (int i = 0; i < size; i++) {
        int c = list1.get(i).compareTo(list2.get(i));
        if (c != 0)
          return c;
      }
      if (size1 < size2)
        return -1;
      if (size1 > size2)
        return 1;
      return 0;
    }
docs: Provides a consistent ordering over lists. First compares by the first
  element. If that element is equal, the next element is considered, and so
  on.