diff --git a/fakeredis.py b/fakeredis.py index 750c67b..19c784e 100644 --- a/fakeredis.py +++ b/fakeredis.py @@ -380,7 +380,7 @@ def sort(self, name, start=None, num=None, by=None, get=None, desc=False, raise redis.RedisError( "RedisError: ``start`` and ``num`` must both be specified") try: - data = self._db[name][:] + data = list(self._db[name])[:] if by is not None: # _sort_using_by_arg mutates data so we don't # need need a return value. diff --git a/test_fakeredis.py b/test_fakeredis.py index 4b8d32e..191e755 100644 --- a/test_fakeredis.py +++ b/test_fakeredis.py @@ -1250,6 +1250,12 @@ def test_sort_with_hash(self): self.redis.sort('foo', by='record_*->age', get='record_*->name'), ['baby', 'teen', 'adult']) + def test_sort_with_set(self): + self.redis.sadd('foo', '3') + self.redis.sadd('foo', '1') + self.redis.sadd('foo', '2') + self.assertEqual(self.redis.sort('foo'), ['1', '2', '3']) + def test_pipeline(self): # The pipeline method returns an object for # issuing multiple commands in a batch.