code: def _isbn_pairing(items):
      
      NameWrapper = namedtuple("NameWrapper", ["name", "obj"])
      metas = map(
          lambda x: NameWrapper(_just_name(x.filename), x),
          filter(lambda x: isinstance(x, MetadataFile), items)
      )
      ebooks = map(
          lambda x: NameWrapper(_just_name(x.filename), x),
          filter(lambda x: isinstance(x, EbookFile), items)
      )
  
      # simple pairing mechanism, which shouldn't be O^2 complex, but something
      # slightly better
      metas = sorted(metas, key=lambda x: x.name)
      ebooks = sorted(ebooks, key=lambda x: x.name, reverse=True)
      while metas:
          meta = metas.pop()
  
          if not isbn_validator.is_valid_isbn(meta.name):
              continue
  
          if not ebooks:
              break
  
          ebook_index = _index(ebooks, meta.name, key=lambda x: x.name)
  
          if ebook_index >= 0:
              logger.debug(
                  "Pairing '%s' and '%s'." % (
                      meta.obj.filename,
                      ebooks[ebook_index].obj.filename
                  )
              )
              items.append(
                  DataPair(
                      metadata_file=meta.obj,
                      ebook_file=ebooks[ebook_index].obj
                  )
              )
              items.remove(meta.obj)
              items.remove(ebooks[ebook_index].obj)
              ebooks = ebooks[ebook_index+1:]
  
      return items
docs: Pair `items` with same ISBN into `DataPair` objects.
  
      Args:
          items (list): list of items, which will be searched.
  
      Returns:
          list: list with paired items. Paired items are removed, `DataPair` is \
                added instead.