from typing import List


def make_pos_array_and_diff(trials: List[dict]) -> List[dict]:
    """

    Parameters
    ----------
    trials : Non-filtered refinement trials

    Returns
    -------
    A list of dictionaries with updated position and difference of neighbours
    """

    _trials = trials[:]
    for i, c in enumerate(trials):
        x_array = sorted([d['pos'] for d in trials[i]['comb']])
        _trials[i]['pos_array'] = x_array
        _trials[i]['diff_array'] = [x_array[i] - x_array[i + 1] for i in range(len(x_array) - 1)]
        # print(x_array)
        # print(len(trials))
        # trials[i]['comb']
    return _trials