home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / sampler / 02 / sort / sort1.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-02-29  |  605 b   |  24 lines

  1. procedure Sort;
  2. {
  3.    preconditions:  List is an array[1..Limit] of Integer
  4.                    Count is of type Word
  5.                      and in the range 0..Limit
  6.    postconditions: The elements 1..Count of List are sorted
  7.                      in ascending order
  8. }
  9. var
  10.   Top,Min,K,Temp : Integer;
  11. begin
  12.   for Top := 1 to Count-1 do begin
  13.     Min := Top;
  14.     for K := Top+1 to Count do
  15.       if List[K] < List[Min]
  16.         then Min := K;
  17.     if Top <> Min then begin
  18.       Temp := List[Top];
  19.       List[Top] := List[Min];
  20.       List[Min] := Temp
  21.     end
  22.   end
  23. end; { of proc Sort }
  24.