(*
 * Selection sort
 *
 * Example:
 *
 *      <3 1 4 1 5 9 2> : SelSort == <1 1 2 3 4 5 9>
 *
 * The sequence must be numeric.
 *)
DEF SelSort AS
   IF [length,#2] | < THEN id
   ELSE 
      [INSERT min END,id] | distl |
      [
         FILTER  = END | EACH 2 END,
         FILTER ~= END | EACH 2 END | SelSort
      ] | cat
   END;

