node-buffertools
node-buffertools copied to clipboard
Compare obey lexicographical order
I suppose this is not technically a bug, but it would be great to have compare act more like a standard comparison algorithm so that buffers can be sorted "properly". That is, sorting buffers containing ascii text should sort the same way as sorting the same text lexicographically.
So, if you have the following buffers with the following bytes: A: 00 00 00 00 (length 4) B: ff ff (length 2) C: ff ff 00 (length 3) D: ff ff 01 (length 3)
They should sort as A, B, C, D. The current compare algorithm would cause them to be sorted as B, C, D, A.
Not unreasonable. Want to try your hand at a patch?