def create_sorted_stats_dfs(df):
    """ Takes a dataframe with phrase as index, percentage docs of all years, 3 Mann-Kendall statistic-related columns, and
    3 Theil-Sen slope-related columns, produces 5 dataframes: (i) phrases with increasing trend (in descending order of
    Mann-Kendall Z), (ii) phrases with decreasing trend (in ascending order, i.e. high negative values first)
    of Mann-Kendall Z), (iii) phrases which show no trend according to Mann Kendall (p-value>0.05), (iv) phrases with postive
    theil-sen slope (in descending order), (v) phrases with negative theil-sen slope (in ascending order).
    """
    increasing_mk = df[df.trend_type_mk=='increasing']
    increasing_mk = increasing_mk.sort_values(by='mannkendall_z', ascending=False)
    decreasing_mk = df[df.trend_type_mk=='decreasing']
    # Ascending order for negative: we want high negative values to be first.
    decreasing_mk = decreasing_mk.sort_values(by='mannkendall_z')
    notrend_mk = df[df.trend_type_mk=='no trend']
    # Ascending order by pvalue: values closer to 0.05 first
    notrend_mk = notrend_mk.sort_values(by='mann_kendall_pvalue')

    positive_theilsen = df[df.theilsen_slope>0]
    positive_theilsen = positive_theilsen.sort_values(by='theilsen_slope', ascending=False)
    negative_theilsen = df[df.theilsen_slope<0]
    negative_theilsen = negative_theilsen.sort_values(by='theilsen_slope')
    return increasing_mk, decreasing_mk, notrend_mk, positive_theilsen, negative_theilsen