# Buggy code
def sort_values(
    self, return_indexer=False, ascending=True, key: Optional[Callable] = None
):
    """
    Return a sorted copy of the index.

    Return a sorted copy of the index, and optionally return the indices
    that sorted the index itself.

    Parameters
    ----------
    return_indexer : bool, default False
        Should the indices that would sort the index be returned.
    ascending : bool, default True
        Should the index values be sorted in an ascending order.
    key : callable, optional
        If not None, apply the key function to the index values
        before sorting. This is similar to the `key` argument in the
        builtin :meth:`sorted` function, with the notable difference that
        this `key` function should be *vectorized*. It should expect an
        ``Index`` and return an ``Index`` of the same shape.

        .. versionadded:: 1.1.0

    Returns
    -------
    sorted_index : pandas.Index
        Sorted copy of the index.
    indexer : numpy.ndarray, optional
        The indices that the index itself was sorted by.

    See Also
    --------
    Series.sort_values : Sort values of a Series.
    DataFrame.sort_values : Sort values in a DataFrame.

    Examples
    --------
    >>> idx = pd.Index([10, 100, 1, 1000])
    >>> idx
    Int64Index([10, 100, 1, 1000], dtype='int64')

    Sort values in ascending order (default behavior).

    >>> idx.sort_values()
    Int64Index([1, 10, 100, 1000], dtype='int64')

    Sort values in descending order, and also get the indices `idx` was
    sorted by.

    >>> idx.sort_values(ascending=False, return_indexer=True)
    (Int64Index([1000, 100, 10, 1], dtype='int64'), array([3, 1, 0, 2]))
    """
    idx = ensure_key_mapped(self, key)

    _as = idx.argsort()
    if not ascending:
        _as = _as[::-1]

    sorted_index = self.take(_as)

    if return_indexer:
        return sorted_index, _as
    else:
        return sorted_index


# Traceback (TypeError)
import pandas as pd
pd.__version__
'1.1.0'
sr = pd.Series(['a',None,'c',None,'e'])
sr.sort_values()
0       a
2       c
4       e
1    None
3    None
dtype: object
idx = pd.Index(['a',None,'c',None,'e'])
idx
Index(['a', None, 'c', None, 'e'], dtype='object')
idx.sort_values()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/pgali/PycharmProjects/del/venv1/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 4448, in sort_values
_as = idx.argsort()
File "/Users/pgali/PycharmProjects/del/venv1/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 4563, in argsort
return result.argsort(*args, **kwargs)
TypeError: '<' not supported between instances of 'NoneType' and 'str'

# Fixed code
def sort_values(
    self,
    return_indexer=False,
    ascending=True,
    na_position: str_t = "last",
    key: Optional[Callable] = None,
):
    """
    Return a sorted copy of the index.

    Return a sorted copy of the index, and optionally return the indices
    that sorted the index itself.

    Parameters
    ----------
    return_indexer : bool, default False
        Should the indices that would sort the index be returned.
    ascending : bool, default True
        Should the index values be sorted in an ascending order.
    na_position : {'first' or 'last'}, default 'last'
        Argument 'first' puts NaNs at the beginning, 'last' puts NaNs at
        the end.

        .. versionadded:: 1.2.0

    key : callable, optional
        If not None, apply the key function to the index values
        before sorting. This is similar to the `key` argument in the
        builtin :meth:`sorted` function, with the notable difference that
        this `key` function should be *vectorized*. It should expect an
        ``Index`` and return an ``Index`` of the same shape.

        .. versionadded:: 1.1.0

    Returns
    -------
    sorted_index : pandas.Index
        Sorted copy of the index.
    indexer : numpy.ndarray, optional
        The indices that the index itself was sorted by.

    See Also
    --------
    Series.sort_values : Sort values of a Series.
    DataFrame.sort_values : Sort values in a DataFrame.

    Examples
    --------
    >>> idx = pd.Index([10, 100, 1, 1000])
    >>> idx
    Int64Index([10, 100, 1, 1000], dtype='int64')

    Sort values in ascending order (default behavior).

    >>> idx.sort_values()
    Int64Index([1, 10, 100, 1000], dtype='int64')

    Sort values in descending order, and also get the indices `idx` was
    sorted by.

    >>> idx.sort_values(ascending=False, return_indexer=True)
    (Int64Index([1000, 100, 10, 1], dtype='int64'), array([3, 1, 0, 2]))
    """
    idx = ensure_key_mapped(self, key)

    # GH 35584. Sort missing values according to na_position kwarg
    # ignore na_position for MutiIndex
    if not isinstance(self, ABCMultiIndex):
        _as = nargsort(items=idx, ascending=ascending, na_position=na_position, key=key)
    else:
        _as = idx.argsort()
        if not ascending:
            _as = _as[::-1]

    sorted_index = self.take(_as)

    if return_indexer:
        return sorted_index, _as
    else:
        return sorted_index