class_docstr: This object implements a general K-way external merge sort for Python
  objects.
  
  >>> pool = MergePool()
  >>> # Add an unlimited number of items in any order
  >>> for item in my_items:
  ...     pool.add(item)
  ...
  >>> # Get the items back in sorted order
  >>> for item in pool.items():
  ...     print(item)
  
  This class uses the `marshal` module to write the items to temporary files,
  so you can only sort marshal-able types (generally: numbers, strings,
  tuples, lists, and dicts).
class_docstr_tok: ["This","object","implements","a","general","K-way","external","merge","sort","for","Python","objects",".",">",">",">","pool","=","MergePool","(",")",">",">",">","#","Add","an","unlimited","number","of","items","in","any","order",">",">",">","for","item","in","my_items",":","...","pool.add","(","item",")","...",">",">",">","#","Get","the","items","back","in","sorted","order",">",">",">","for","item","in","pool.items","(",")",":","...","print","(","item",")","This","class","uses","the","`","marshal","`","module","to","write","the","items","to","temporary","files",",","so","you","can","only","sort","marshal-able","types","(","generally",":","numbers",",","strings",",","tuples",",","lists",",","and","dicts",")","."]
docstr: Returns a sorted list or iterator of the items in the pool.
  
  :param maxfiles: maximum number of files to open at once.
docstr_tok: ["Returns","a","sorted","list","or","iterator","of","the","items","in","the","pool",".",":","param","maxfiles",":","maximum","number","of","files","to","open","at","once","."]
code: def items(self, maxfiles=128):
      """Returns a sorted list or iterator of the items in the pool.
  
      :param maxfiles: maximum number of files to open at once.
      """
  
      if maxfiles < 2:
          raise ValueError("maxfiles=%s must be >= 2" % maxfiles)
  
      if not self.runs:
          # We never wrote a run to disk, so just sort the queue in memory
          # and return that
          return sorted(self.current)
      # Write a new run with the leftover items in the queue
      self.save()
  
      # If we have more runs than allowed open files, merge some of the runs
      if maxfiles < len(self.runs):
          self.reduce_to(maxfiles, maxfiles)
  
      # Take all the runs off the run list and merge them
      runs = self.runs
      self.runs = []  # Minor detail, makes this object reusable
      return self._merge_runs(runs)
  
file_path: whoosh/src/whoosh/externalsort.py
imports: from __future__ import with_statement
  import os, tempfile
  from heapq import heapify, heappop, heapreplace
  from whoosh.compat import dump, load
label_desc: Use image node_id 13 for calling the SortingPool obj's underlying member method code with example usage: obj.items(maxfiles) and returns: self, sorted