bnoordhuis / node-buffertools

working with node.js buffers made easy
ISC License
205 stars 35 forks source link

Compare obey lexicographical order #25

Open dfoody opened 12 years ago

dfoody commented 12 years ago

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.

bnoordhuis commented 12 years ago

Not unreasonable. Want to try your hand at a patch?