code: def sort(self, key, start=None, num=None, by=None, get=None,
               desc=False, alpha=False, store=None, groups=False):
          '''Sort and return the list, set or sorted set at ``key``.
          ``start`` and ``num`` allow for paging through the sorted data
          ``by`` allows using an external key to weight and sort the items.
              Use an "*" to indicate where in the key the item value is located
          ``get`` allows for returning items from external keys rather than the
              sorted data itself.  Use an "*" to indicate where int he key
              the item value is located
          ``desc`` allows for reversing the sort
          ``alpha`` allows for sorting lexicographically rather than numerically
          ``store`` allows for storing the result of the sort into
              the key ``store``
          ``groups`` if set to True and if ``get`` contains at least two
              elements, sort will return a list of tuples, each containing the
              values fetched from the arguments to ``get``.
          '''
          if ((start is not None and num is None) or
                  (num is not None and start is None)):
              raise CommandError("``start`` and ``num`` must both be specified")
          pieces = [key]
          if by is not None:
              pieces.append('BY')
              pieces.append(by)
          if start is not None and num is not None:
              pieces.append('LIMIT')
              pieces.append(start)
              pieces.append(num)
          if get is not None:
              if isinstance(get, str):
                  pieces.append('GET')
                  pieces.append(get)
              else:
                  for g in get:
                      pieces.append('GET')
                      pieces.append(g)
          if desc:
              pieces.append('DESC')
          if alpha:
              pieces.append('ALPHA')
          if store is not None:
              pieces.append('STORE')
              pieces.append(store)
          if groups:
              if not get or isinstance(get, str) or len(get) < 2:
                  raise CommandError('when using "groups" the "get" argument '
                                     'must be specified and contain at least '
                                     'two keys')
          options = {'groups': len(get) if groups else None}
          return self.execute_command('SORT', *pieces, **options)