def fix_order(correct_order, new_order, sorting):
    """
    Fixes the order of a list in `sorting` with `new_order` to
    match the index order layed out in `correct_order`.

    Parameters
    ----------
    correct_order : list.
        contains keys in the correct order, guides sorting of the list `sorting`
    new_order : list.
        contains same set of keys in correct_order, but in a different order.
    sorting : list.
        list to be sorted based on the order in `correct_order`.
    """
    if correct_order == new_order:
        return sorting, new_order
    new_idx_order = []
    for i in correct_order:
        new_idx_order += [new_order.index(i)]
    reordered_vals = []
    reordered_keys = []
    for i in range(len(new_idx_order)):
        reordered_vals += [sorting[new_idx_order[i]]]
        reordered_keys += [new_order[new_idx_order[i]]]
    assert correct_order == reordered_keys, 'keys not correctly ordered in `fix_order()`'
    return reordered_vals, reordered_keys
