code: def _get_sorted_iterator(self, iterator):
          
          lines = list(next(iterator))
          if len(lines) < self.max_lines:
              return iter(sorted(lines, key=self.key))
  
          import tempfile
          tmp_dir = tempfile.mkdtemp()
          fnames = self._split(chain([lines], iterator), tmp_dir)
          return SortedIteratorMerger([unpickle_iter(open(fname, 'rb')) for fname in fnames], self.key)
docs: Get the iterator over the sorted items.
  
          This function decides whether the items can be sorted in memory or on disk.
          :return: