Java tutorial
//package com.java2s; import com.google.common.collect.Ordering; import java.util.*; public class Main { public static <T> boolean isNaturalSortedSet(Iterable<? extends T> it) { if (it instanceof SortedSet) { SortedSet<? extends T> sortedSet = (SortedSet<? extends T>) it; Comparator<?> comparator = sortedSet.comparator(); return (comparator == null) || comparator.equals(Ordering.natural()); } return false; } }