home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MISC / IFP05.ZIP / FPDEMO.EXE / MERGESOR < prev    next >
Encoding:
Text File  |  1987-02-09  |  488 b   |  22 lines

  1. (*
  2.  * MergeSort
  3.  *
  4.  * This function sorts a sequence of numbers or strings into ascending order
  5.  * using merge sort.
  6.  *
  7.  * Examples:
  8.  *
  9.  *      <3 1 4 1 5 9 2> : MergeSort == <1 1 2 3 4 5 9>
  10.  *
  11.  *      <all work and no play> : MergeSort == <all and no play work>
  12.  *
  13.  * The sequence may not mix strings and numbers.
  14.  *)
  15. DEF MergeSort AS
  16.    IF [length,#2] | < THEN id
  17.    ELSE
  18.        [id, [length,#2] | div] |
  19.        [takel,dropl] | EACH MergeSort END | Merge
  20.    END;
  21.  
  22.