code: def revert_unordered_batches(self):
          
          i = 0
          for key in sorted(self.batches.keys(), reverse=True):
              if compare_3PC_keys(self.last_ordered_3pc, key) > 0:
                  ledger_id, discarded, _, prevStateRoot, len_reqIdr = self.batches.pop(key)
                  discarded = invalid_index_serializer.deserialize(discarded)
                  self.logger.debug('{} reverting 3PC key {}'.format(self, key))
                  self.revert(ledger_id, prevStateRoot, len_reqIdr - len(discarded))
                  i += 1
              else:
                  break
          return i
docs: Revert changes to ledger (uncommitted) and state made by any requests
          that have not been ordered.