o Summary
  bedmergesort will sort your largest bed-like input file, first by chromosome (lexicographically), then by the start coordinate values and finally by the second coordinate values.

o Usage:
  bedmergesort [ -maxLinesPerFile 100000 -maxOpenFiles 10 -resultsFile results.bed -verbose 1 ] <inputfile>

o Precondition:
  setops must be in your PATH.

o Main Idea:
  Break up a huge .bed-like file into several smaller .bed-like files, sorting each lexicographically, then unionize all smaller files into final result using setops.

-maxLinesPerFile is the maximum (and target) number of lines each smaller subfile can have.  This number also corresponds to the maximum number of lines that will be sorted at any one time (read into main memory at any one time).  So, you have direct control over your memory requirements.

-maxOpenFiles is the maximum (and target) number of files that will be opened at the same time in setops during merging.  It is best to use the largest number possible here, but there will ultimately be constraints imposed by the OS: number of file descriptors you can have open in one program.  The default is probably lower than what is possible.

-resultsFile is where we place the final results.

-verbose is either 1 or 0.  If 1, then system calls made to "setops -u" will be sent to standard error.
