Uses sorting from the Java API for both primitive types and objects.