src/main/java/com/googlecode/objectify/Key.java
@Override
	public int compareTo(final Key<?> other) {
		if (this.raw == other.raw) {
			return 0;
		}

		{
			final int result = this.raw.getProjectId().compareTo(other.raw.getProjectId());
			if (result != 0)
				return result;
		}

		{
			final int result = this.raw.getNamespace().compareTo(other.raw.getNamespace());
			if (result != 0)
				return result;
		}

		{
			final int result = this.compareAncestors(other);
			if (result != 0)
				return result;
		}

		{
			// Too bad PathElement and Key don't share any kind of interface grrr
			final int result = this.getRaw().getKind().compareTo(other.getRaw().getKind());
			if (result != 0) {
				return result;
			}
			else if (this.raw.getNameOrId() == null && other.raw.getNameOrId() == null) {
				return compareToWithIdentityHash(this.raw, other.raw);
			}
			else if (this.raw.hasId()) {
				return other.raw.hasId() ? Long.compare(this.raw.getId(), other.raw.getId()) : -1;
			}
			else {
				return other.raw.hasId() ? 1 : this.raw.getName().compareTo(other.raw.getName());
			}
		}
	}
@Override
	public int compareTo(final Key<?> other) {
		if (this.raw == other.raw) {
			return 0;
		}

		{
			final int result = this.raw.getProjectId().compareTo(other.raw.getProjectId());
			if (result != 0)
				return result;
		}

		{
			final int result = this.raw.getNamespace().compareTo(other.raw.getNamespace());
			if (result != 0)
				return result;
		}

		{
			final int result = this.compareAncestors(other);
			if (result != 0)
				return result;
		}

		{
			// Too bad PathElement and Key don't share any kind of interface grrr
			final int result = this.getRaw().getKind().compareTo(other.getRaw().getKind());
			if (result != 0) {
				return result;
			}
			else if (this.raw.getNameOrId() == null && other.raw.getNameOrId() == null) {
				return compareToWithIdentityHash(this.raw, other.raw);
			}
			else if (this.raw.hasId()) {
				return other.raw.hasId() ? Long.compare(this.raw.getId(), other.raw.getId()) : -1;
			}
			else {
				return other.raw.hasId() ? 1 : this.raw.getName().compareTo(other.raw.getName());
			}
		}
	}
<p>The new cloud sdk Key doesn't have compareTo(), so we reimplement the logic from the old GAE SDK.</p>