/** * Compares this UUID with the specified UUID. * * The first of two UUIDs is greater than the second if the most * significant field in which the UUIDs differ is greater for the first * UUID. * * Q. What's the value of being able to sort UUIDs?<br> * A. Use them as keys in a B-Tree or similar mapping. * * @param Uuid $uuid UUID to which this UUID is to be compared * @return int -1, 0 or 1 as this UUID is less than, equal to, or greater than $uuid */ public function compareTo(Uuid $uuid) { $comparison = null; if ($this->getMostSignificantBitsHex() < $uuid->getMostSignificantBitsHex()) { $comparison = -1; } elseif ($this->getMostSignificantBitsHex() > $uuid->getMostSignificantBitsHex()) { $comparison = 1; } elseif ($this->getLeastSignificantBitsHex() < $uuid->getLeastSignificantBitsHex()) { $comparison = -1; } elseif ($this->getLeastSignificantBitsHex() > $uuid->getLeastSignificantBitsHex()) { $comparison = 1; } else { $comparison = 0; } return $comparison; }