def sort(docids, reverse=False, limit=None):
    """Sort document ids sequence using indexed values

        If some of docids are not indexed they are skipped
        from resulting iterable.

        Return a sorted iterable of document ids. Limited by
        value of the "limit" argument and optionally
        reversed, using the "reverse" argument.
        """
