home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / sorting.swg / 0001_ALPHAREC.PAS.pas next >
Encoding:
Pascal/Delphi Source File  |  1993-05-28  |  756 b   |  32 lines

  1. { Alphabetic Rec Sort }
  2.  
  3. Procedure SortIt(Key : Byte);
  4. Var
  5.   I, J : Byte;
  6.  
  7. Procedure Swapper;
  8. Var
  9.   T : Member;
  10.  
  11. begin
  12.   T := Memrec[I];
  13.   MemRec[I] := MemRec[J];
  14.   MemRec[J] := T;
  15. end;
  16.  
  17. begin
  18.   For I := 1 to MaxMem - 1 DO
  19.    For J := I To MaxMem do begin
  20.      Case Key OF
  21.        1 : if MemRec[I].Firstname < MemRec[J].FirstName then Swapper;
  22.        2 : if MemRec[I].LastName  < MemRec[J].LastName  then Swapper;
  23.        3 : if MemRec[I].Points    < MemRec[J].Points    then Swapper;
  24.      end;
  25. end;
  26.  
  27. {
  28. Another Alternative would be to do as C does, make a Generic Sort routine
  29. where you pass it a Function that returns > 0 if Record1 is greater than
  30. Record2, < 0 if Record1 is Less than Record2, and 0 if they are the same.
  31. }
  32.