def sort_params_by_block(parameters, mixings):
    """
    Returns a dictionary of the LH blocks of a new model,
    with all entries.

    The dict looks like: 

    {
        # A block with many entries
        SMINPUTS : { 1: alphainv, 2: GF, 3: alphaS, ... }, 

        # A block with just one entry, i.e. matrices:
        YE : { matrix: 3x3 },         # e.g. Yukawas

        # A matrix block with a different outputname in SPheno,
        # e.g. for the THDM
        SCALARMIX : { mixingmatrix: 2x2, outputname: ZH }
        ...
    }
    """

    params_by_block = {}

    for par in parameters:

        # If there's no block, we can't really add it to this dict.
        if not par.block:
            continue

        shape = par.shape

        matrix = False
        if shape:
            if shape.startswith('m'): 
                matrix = True

        try:
          mixings[par.name]
          is_mixing = True
        except:
          is_mixing = False

        # If it's a matrix then it will be a new block
        if matrix:
            # if it's a mixing matrix, save the outputname (SPheno) and the
            # particle eigenstates (as known by SARAH) to the entry.
            if par.is_output and is_mixing :
                newentry = { "mixingmatrix": shape[1:], 
                             "outputname": par.name,
                             "particles" : mixings[par.name] }
            else:
                newentry = { "matrix": shape[1:], 
                             "outputname": par.name }
            params_by_block[par.block] = newentry

        # If it's not a matrix and is a new block, then create the entry
        elif par.block not in params_by_block:
            newentry = { par.index : par.name }
            params_by_block[par.block] = newentry

        # If the block already exists, add to it
        elif par.block in params_by_block:
            params_by_block[par.block][par.index] = par.name

    return params_by_block