code: def _merge_sorted_items(self, index):
          def load_partition(j):
              path = self._get_spill_dir(j)
              p = os.path.join(path, str(index))
              with open(p, 'rb', 65536) as f:
                  for v in self.serializer.load_stream(f):
                      yield v
          disk_items = [load_partition(j) for j in range(self.spills)]
          if self._sorted:
              sorted_items = heapq.merge(disk_items, key=operator.itemgetter(0))
          else:
              ser = self.flattened_serializer()
              sorter = ExternalSorter(self.memory_limit, ser)
              sorted_items = sorter.sorted(itertools.chain(*disk_items),
                                           key=operator.itemgetter(0))
          return ((k, vs) for k, vs in GroupByKey(sorted_items))