Lexicographical ordering for integers. Produces []byte and hex string
encodings of integers that maintain the same ordering before and after encoding.
From the implementation by substack.
import (
lexi "github.com/filwisher/lexi-int"
)
func property(a, b uint32) bool {
astr := lexi.PackHex(uint(a))
bstr := lexi.PackHex(uint(b))
if a < b {
return astr < bstr
} else if a > b {
return astr > bstr
} else {
return astr == bstr
}
}$ go get https://github.com/substack/lexicographic-integer