class_docstr: ExternalSorter will divide the elements into chunks, sort them in
  memory and dump them into disks, finally merge them back.
  
  The spilling will only happen when the used memory goes above
  the limit.
  
  Examples
  --------
  >>> sorter = ExternalSorter(1)  # 1M
  >>> import random
  >>> l = list(range(1024))
  >>> random.shuffle(l)
  >>> sorted(l) == list(sorter.sorted(l))
  True
  >>> sorted(l) == list(sorter.sorted(l, key=lambda x: -x, reverse=True))
  True
class_docstr_tok: ["ExternalSorter","will","divide","the","elements","into","chunks",",","sort","them","in","memory","and","dump","them","into","disks",",","finally","merge","them","back",".","The","spilling","will","only","happen","when","the","used","memory","goes","above","the","limit",".","Examples","--","--","--","--",">",">",">","sorter","=","ExternalSorter","(","1",")","#","1M",">",">",">","import","random",">",">",">","l","=","list","(","range","(","1024",")",")",">",">",">","random.shuffle","(","l",")",">",">",">","sorted","(","l",")","==","list","(","sorter.sorted","(","l",")",")","True",">",">",">","sorted","(","l",")","==","list","(","sorter.sorted","(","l",",","key=lambda","x",":","-x",",","reverse=True",")",")","True"]
docstr: Choose one directory for spill by number n
docstr_tok: ["Choose","one","directory","for","spill","by","number","n"]
code: def _get_path(self, n):
      """Choose one directory for spill by number n"""
      d = self.local_dirs[n % len(self.local_dirs)]
      if not os.path.exists(d):
          os.makedirs(d)
      return os.path.join(d, str(n))
  
imports: import os
  import platform
  import shutil
  import warnings
  import gc
  import itertools
  import operator
  import random
  import sys
  import heapq
  from pyspark.serializers import BatchedSerializer, CPickleSerializer, FlattenedValuesSerializer, CompressedSerializer, AutoBatchedSerializer
  from pyspark.util import fail_on_stopiteration
label_desc: Use image node_id 2 for calling the ExternalSorter obj's underlying member method code with example usage: obj._get_path(n) and returns: os