home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / euphoria / simple.ex < prev    next >
Text File  |  1994-01-31  |  561b  |  24 lines

  1.     --------------------------------
  2.     -- A very simple sort program --
  3.     --------------------------------
  4. with trace -- compile for tracing
  5. trace(1)   -- turn on tracing
  6.  
  7. function simple_sort(sequence x)
  8. object temp 
  9.     for i = 1 to length(x) - 1 do
  10.     for j = i + 1 to length(x) do
  11.         if compare(x[j],x[i]) < 0 then
  12.         temp = x[j]
  13.         x[j] = x[i]
  14.         x[i] = temp
  15.         end if
  16.     end for
  17.     end for
  18.     return x
  19. end function
  20.  
  21. -- Hold down the Enter key and 
  22. -- watch x get sorted before your eyes! 
  23. ? simple_sort( {9, 10, 3, 1, 4, 5, 8, 7, 6, 2} )
  24.