def iorder(hub, name, state):
    """
    Take a state and apply the iorder system
    """
    for id_ in state:
        for s_dec in state[id_]:
            if not isinstance(s_dec, str):
                continue
            if not isinstance(state[id_], dict):
                continue
            if not isinstance(state[id_][s_dec], list):
                continue
            found = False
            if s_dec.startswith('_'):
                continue
            for arg in state[id_][s_dec]:
                if isinstance(arg, dict):
                    if len(arg) > 0:
                        if next(iter(arg)) == 'order':
                            found = True
            if not found:
                if not isinstance(state[id_][s_dec], list):
                    continue
                state[id_][s_dec].append({'order': hub.idem.RUNS[name][
                    'iorder']})
                hub.idem.RUNS[name]['iorder'] += 1
