code: def sort(items, maxsize=100000, tempdir=None, maxfiles=128):
      """Sorts the given items using an external merge sort.
  
      :param tempdir: the path of a directory to use for temporary file
          storage. The default is to use the system's temp directory.
      :param maxsize: the maximum number of items to keep in memory at once.
      :param maxfiles: maximum number of files to open at once.
      """
  
      p = SortingPool(maxsize=maxsize, tempdir=tempdir)
      for item in items:
          p.add(item)
      return p.items(maxfiles=maxfiles)
  
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 1 for calling a global function with example usage: sort(items, maxsize, tempdir, maxfiles) and returns: p