You can use http://guava-libraries.googlecode.com/svn/tags/release08/javadoc/com/google/common/primitives/UnsignedBytes.html#lexicographicalComparator%28%29 which compares 8 bytes at a time