Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50150/sort.sno
There are 2 other files named sort.sno in the archive. Click here to see a list.
* BUBBLE SORT PROGRAM SIMILIAR TO THE ONE ON PAGE 111
* OF THE REFERENCE MANUAL. IT SORTS A TWO DIMENSIONAL ARRAY.
* THE ARGUMENTS ARE
*       ARRAY NAME
*
*       L.P. WADE 3-20-70 DEC
*

        SORTPAT = BREAK(',') . DIM1 ',' REM . DIM2
        DEFINE('SORT(NAME)I,J')
        DEFINE('SWITCH(NAME,DIM1,DIM2,VAR)I,TEMP')
        DEFINE('BUBBLE(NAME,DIM1,DIM2,VAR)')    :(DEFEND)

SORT PROTOTYPE(NAME) SORTPAT    :S(SORT1)
        OUTPUT = 'SORT CANNOT HANDLE THE ARRAY NAMED ' I
        OUTPUT = 'ILLEGAL PROTOTYPE = ' PROTOTYPE(NAME)
.               :(FRETURN)
SORT1   I = LE(I,DIM1) I + 1    :F(RETURN)
	IDENT(NAME<I + 1,1>) :S(RETURN)
        LGT(NAME<I,1>,NAME<I + 1,1>)    :F(SORT1)
        SWITCH(NAME,DIM1,DIM2,I)
        BUBBLE(NAME,DIM1,DIM2,I)        :(SORT1)

SWITCH  I = LE(I,DIM2) I + 1    :F(RETURN)
        TEMP = NAME<VAR,I>
        NAME<VAR,I> = NAME<VAR + 1,I>
        NAME<VAR + 1,I> = TEMP  :(SWITCH)

BUBBLE  VAR = GT(VAR,1) VAR - 1 :F(RETURN)
        LGT(NAME<VAR,1>,NAME<VAR + 1,1>)        :F(RETURN)
        SWITCH(NAME,DIM1,DIM2,VAR)      :(BUBBLE)
DEFEND
        TAB = ' '
        DEFINE('PRINTARRAY(NAME)TEMP,I,J') :(PRINTEND)

PRINTARRAY PROTOTYPE(NAME) SORTPAT      :S(PRINT1)
        OUTPUT = 'PRINTARRAY CANNOT HANDLE ARRAY ' 
        OUTPUT = 'ILLEGAL PROTOTYPE = ' PROTOTYPE(NAME)

                :(FRETURN)
PRINT1  I = NULL
        TEMP = NULL
        J = LE(J,DIM1) J + 1    :F(RETURN)
PRINT2  I = LE(I,DIM2) I + 1    :F(PRINT3)
	EQ(I,1) IDENT(NAME<J,I>) :S(PRINT1)
        TEMP = TEMP TAB NAME<J,I>  :(PRINT2)
PRINT3  OUTPUT = TEMP   :(PRINT1)
PRINTEND









*