View Single Post
  #4  
Old 09-17-2001, 07:41 AM
galen galen is offline
Professional God
Join Date: Mar 2001
Location: Colorado, USA
Posts: 925
galen is on a distinguished road
here, have a shell sort
NPC Code:

Procedure ShellSort(var List: Group; var cntr, cntr2: Integer);
Var {Sorts the words and replaces them in}
loc,
gap, {the array}
maxNum : Integer;
temp : String[4];
change : Boolean;
Begin
ClrScr;
cntr := 0;
cntr2 := 0;
gap := Trunc(max div 2);
While gap > 0 do
Begin
Repeat
change := false;
For loc := min to max - gap do
Begin
inc(cntr2, 1);
If List[loc] > List[loc + gap]
then Begin
temp := List[loc];
List[loc] := List[loc + gap];
List[loc + gap] := temp;
inc(cntr, 1);
change := true;
End;
End;
Until change = false;
gap := Trunc(gap div 2);
End;
End;

__________________
Galen S. Kant
galen "at" terraweb.net
Reply With Quote