/frames 16 def %include /u/rs/book3/pslib/tools.ps %include /u/rs/book3/pslib/example.ps /insertionsort { 1 1 N 1 sub { /lll exch def lll -1 1 { /xxx exch def xxx 1 sub xxx compare { exit } if xxx xxx 1 sub compareswap } for xxx lll SUBFILEx % /frame frame 1 add def % intNode xxx PT % /frame frame 1 sub def } for } def LL RR SUBFILE insertionsort LL RR SUBFILE ---------------------------- T 147pt Insertion sorting example During the first pass of insertion sort, the {\F S} in the second position is larger than the {\F A}, so it doesn't have to be moved. One the second pass, when the {\F O} in the third position is encountered, it is exchanged with the {\F S} to put {\F A} {\F O} {\F S} in sorted order, etc.