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)