def find_parameter_groups(columns):
    """
    Find parameter groups within a list

    This finds all the parameters which should be grouped together into tuples rather
    than being separated. For example, if you have a list like
    ``["CORE_CLIMATESENSITIVITY", "RF_BBAER_DIR_WM2", "OUT_ZERO_TEMP_PERIOD_1", "OUT_ZERO_TEMP_PERIOD_2"]``,
    this function will return
    ``{"OUT_ZERO_TEMP_PERIOD": ["OUT_ZERO_TEMP_PERIOD_1", "OUT_ZERO_TEMP_PERIOD_2"]}``
    which tells you that the parameters
    ``["OUT_ZERO_TEMP_PERIOD_1", "OUT_ZERO_TEMP_PERIOD_2"]`` should be grouped
    together into a tuple with the name ``"OUT_ZERO_TEMP_PERIOD"`` while all the other
    columns don't belong to any group.

    Parameters
    ----------
    list of str
        List of strings to sort

    Returns
    -------
    dict of str: list of str
        Dictionary where the keys are the 'group names' and the values are the list of
        parameters which belong to that group name.
    """
    cols_to_merge = {}
    for c in columns:
        toks = c.split("_")
        start = "_".join(toks[:-1])
        if start.lower() in ["file_emisscen", "out_keydata", "file_tuningmodel"]:
            continue

        try:
            int(toks[-1])  # Check if the last token is an integer
            if start not in cols_to_merge:
                cols_to_merge[start] = []
            cols_to_merge[start].append(c)
        except (ValueError, TypeError):
            continue

    return {k: sorted(v) for k, v in cols_to_merge.items()}