def transform(res):
    """ Transforms dictionary to a list of lists """
    flattened = []
    for name in sorted(res):
        for root in sorted(res[name]):
            for iteration in res[name][root]["peaks"]:
                for peak in res[name][root]["peaks"][iteration]:
                    energy, wave, intensity = peak
                    flattened.append([name, root, iteration, energy, wave, intensity])
    return flattened