Does anyone know of a library for encoding a number of primitive types (like integers, floats, strings, etc) into a string but preserving the lexicographical order of the types?
Ideally, I'm looking for a C++ library, but other languages are fine too. Also, one can assume that the format does not need to be encoded in the string itself (that is, if it's int64/string/float then the encoded string does not need to encode this information, only encoding the data is enough).
Just write numeric values in a fixed column width with leading zeros, and strings as normal. So like this:
Then you can sort as text (e.g. Unix
sort
without-n
). How about that?