def sort_pd(key=None, reverse=False, cmp=None):

    def sorter(series):
        series_list = list(series)
return [series_list.index(i) for i in sorted(series_list, key=key, reverse=
    reverse, cmp=cmp)]
return sorter
Пользовательская сортировка в кадре данных pandas