erikolson186 / zangodb

MongoDB-like interface for HTML5 IndexedDB
https://erikolson186.github.io/zangodb/
MIT License
1.07k stars 72 forks source link

Bug when sorting on multiple fields #5

Closed keithnorm closed 7 years ago

keithnorm commented 7 years ago

I believe because of this line https://github.com/erikolson186/zangodb/blob/master/src/sort.js#L48 when sorting on multiple fields, if the first field comes back from compare with a result of 0 the sort returns without evaluating the second field.

I think the fix is to just change that line to: if (result !== null && result !== 0) { return result; }.

erikolson186 commented 7 years ago

Thank you for pointing this out and suggesting a fix. I went ahead and verified the bug and made the following commit:

https://github.com/erikolson186/zangodb/commit/452057b830915cd556856005ba4dc0292cab228c

keithnorm commented 7 years ago

Great thanks!