def sort_set(input, **params):
    """
    Apply sorting to input dataset
    :param input:
    :param params:
    :return: sorted data
    """
    PARAM_SORT_FIELD = 'sort.field'
    PARAM_SORT_ORDER = 'sort.order'

    df = pd.DataFrame.from_records(input)
    sort_field = params.get(PARAM_SORT_FIELD)
    sort_order = params.get(PARAM_SORT_ORDER) if PARAM_SORT_ORDER in params else None
    if sort_order:
        df[sort_field] = df[sort_field].astype('category')
        df[sort_field].cat.set_categories(sort_order, inplace=True)
    df.sort_values(by=sort_field, inplace=True)
    return Converter.df2list(df)
def sort_set ( input , ** params ) : PARAM_SORT_FIELD = 'sort.field' PARAM_SORT_ORDER = 'sort.order' df = pd . DataFrame . from_records ( input ) sort_field = params . get ( PARAM_SORT_FIELD ) sort_order = params . get ( PARAM_SORT_ORDER ) if PARAM_SORT_ORDER in params else None if sort_order : df [ sort_field ] = df [ sort_field ] . astype ( 'category' ) df [ sort_field ] . cat . set_categories ( sort_order , inplace = True ) df . sort_values ( by = sort_field , inplace = True ) return Converter . df2list ( df )
Apply sorting to input dataset
    :param input:
    :param params:
    :return: sorted data