def sort_shells(shells, use_copy=True):
    if use_copy:
        shells = copy.deepcopy(shells)
    shells = [sort_shell(sh, False) for sh in shells]
    return list(
        sorted(
            shells,
            key=lambda x: (max(x['angular_momentum']), -len(x['exponents']), -len(x['coefficients']), -float(
                max(x['exponents'])))))