def _handle_iorder(self, state):
        '''
        Take a state and apply the iorder system
        '''
        if self.opts['state_auto_order']:
            for name in state:
                for s_dec in state[name]:
                    if not isinstance(s_dec, six.string_types):
                        # PyDSL OrderedDict?
                        continue

                    if not isinstance(state[name], dict):
                        # Include's or excludes as lists?
                        continue
                    if not isinstance(state[name][s_dec], list):
                        # Bad syntax, let the verify seq pick it up later on
                        continue

                    found = False
                    if s_dec.startswith('_'):
                        continue

                    for arg in state[name][s_dec]:
                        if isinstance(arg, dict):
                            if arg:
                                if next(six.iterkeys(arg)) == 'order':
                                    found = True
                    if not found:
                        if not isinstance(state[name][s_dec], list):
                            # quite certainly a syntax error, managed elsewhere
                            continue
                        state[name][s_dec].append(
                                {'order': self.iorder}
                                )
                        self.iorder += 1
        return state