I have a hashmap with byte[] keys. I'd like to sort it through a TreeMap.
What is the most effective way to implement the comparator for lexicographic order?
Using Guava, you can use either of:
The UnsignedBytes
comparator appears to have an optimized form using Unsafe
that it uses if it can. Comments in the code indicate that it may be at least twice as fast as a normal Java implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With