Ensure that scan() results are sorted.

Turns out that the "real" database backends do this already; the "test"
memory backend and the redis backend didn't ensure this, so fix those too.