-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing implementation of IComparable #29
Comments
@Hanskrogh I'm not sure it makes sense semantically. How do you define that one TypeID is smaller or bigger than another? Theoretically, I could compare timestamps but there are edge cases that make it not that easy to define:
|
That’s a fair point regarding the ambiguity when comparing TypeIDs with different prefixes. It’s true that semantically comparing them might not make sense in many cases. However, the solution I’ve provided focuses purely on the GUID portion of the TypeID for comparison, leaving it up to the individual programmer to decide whether comparing TypeIDs with different prefixes is meaningful for their use case. Regarding UUIDv7, its entire purpose is to ensure comparability based on timestamps, and this implementation adheres to that principle by performing a byte-level comparison of the GUID in big-endian order. This approach preserves the natural ordering of UUIDv7, which is inherently timestamp-based. If two TypeIDs have different prefixes and you still want to compare them, this implementation will default to the underlying GUID order. While this might not always be semantically meaningful, it provides a consistent fallback behavior for scenarios where such comparisons are unavoidable. Ultimately, the responsibility of ensuring prefix alignment or handling edge cases like identical timestamps would remain with the programmer or the broader application logic. This implementation simply offers a deterministic and timestamp-respecting way to compare TypeIDs when the GUID portion is the focus. |
is this something that could be added?
The text was updated successfully, but these errors were encountered: