@transformer<EOL>def sort_set(input, **params):
PARAM_SORT_FIELD = '<STR_LIT>'<EOL>PARAM_SORT_ORDER = '<STR_LIT>'<EOL>df = pd.DataFrame.from_records(input)<EOL>sort_field = params.get(PARAM_SORT_FIELD)<EOL>sort_order = params.get(PARAM_SORT_ORDER) if PARAM_SORT_ORDER in params else None<EOL>if sort_order:<EOL><INDENT>df[sort_field] = df[sort_field].astype('<STR_LIT>')<EOL>df[sort_field].cat.set_categories(sort_order, inplace=True)<EOL><DEDENT>df.sort_values(by=sort_field, inplace=True)<EOL>return Converter.df2list(df)<EOL>
Apply sorting to input dataset
:param input:
:param params:
:return: sorted data