- ensure tmpIndex is reset when the tmpSet is merged with the sparseSet
- only sort values in the encodedSet up to a specified index to prevent uninitialized values from polluting result
- fix failing tests and add a new test of a single element