%! % % Sort Routine in PostScript (R) % % by Andrew Marc Greene % Dec. 1987 % % [PostScript is a trademark of Adobe Systems, Inc.] % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Prepare to print list (select font, position cursor) 72 770 moveto % Initialize num, which will contain number of items to sort /num 0 def % Get list of items to sort FontDirectory { pop /st 70 string def /num num 1 add def st cvs } forall %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Sort Routines % Compare top element to current "best" % If top element is "better," switch them, % otherwise leave top element on top; % then roll the stack /OneComp { /elt exch def elt best gt {best /best elt def} {elt} ifelse n 1 roll } def % Go through n items one time, leaving "best" item on bottom % Then decrement n and, if n>0, recursively call NComp /NComp { /best exch def /n n 1 sub def 1 1 n {pop OneComp} for best n 1 add 1 roll n 0 gt {NComp} if } def % Initialize n to the number of elements to sort (num) % and begin the sort /n num def NComp %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % font-show % Passed a string (the name of a font), % Displays that string in its own font (12 scale) /fshow { dup cvn findfont 12 scalefont setfont show } def /oldtype 0 def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Display the sorted elements 1 1 num {pop dup dup 1 get exch 2 get 256 mul add /newtype exch def newtype oldtype ne { 0 -15 rmoveto /oldtype newtype def} if currentpoint 3 -1 roll fshow 13 sub moveto } for showpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % /mit/amgreene/PS/dictshow.ps % by Andrew Marc Greene Dec 1987 % End of File %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .