program GPQDemo;

{ Programm zur Demonstration des General-Purpose-Quicksort. }

uses
   GenPurQuick;

const
   TableSize = 20;
   StrMax    = 8;

type
   PSortStr = ^String[StrMax];

var
   Table     : Array[1..TableSize] of Pointer;
   Index     : LongInt;
   CharIndex : LongInt;
   s	     : PSortStr;

{ Ist Arg1 < Arg2 ? }
function Smaller(Arg1 : Pointer; Arg2 : Pointer) : Boolean;
begin
   if PSortStr(Arg1)^ < PSortStr(Arg2)^ then
      Smaller := True
   else Smaller := False;
end;

begin
   Randomize;
   for Index := 1 to TableSize do
   begin
      New(s);
      for CharIndex := 1 to StrMax do s^ := s^ + Chr(Ord('a') + Random(26));
      Writeln(s^);
      Table[Index] := s;
   end;
   Writeln;
   ArrSort(Table,@Smaller);
   for Index := 1 to TableSize do
   begin
      s := Table[Index];
      Writeln(s^);
      Dispose(s);
   end;
end.
