# PIKSRT - Sort an array into ascending numerical order, by straight # insertion of sorting. This is most efficient for sorting samples less # than about 20. Adapted from Numerical Recipes by Press et. al. 2nd ed. # (1992), p.321. procedure piksrt (arr, n) real arr[*] # input/output: sample array, sorted into # ascending order on output int n # number of samples int i, j real a #============================================================================== begin do j = 2, n { a = arr[j] do i = j-1, 1, -1 { if (arr[i] <= a) goto 10 arr[i+1] = arr[i] } i = 0 10 arr[i+1] = a } end # PIKSR2 - Sort an array into ascending numerical order while making the # corresponding rearrangement of a second array, by straight # insertion of sorting. This is most efficient for sorting samples less # than about 20. Adapted from Numerical Recipes by Press et. al. 2nd ed. # (1992), p.321. procedure piksr2 (arr, brr, n) real arr[*] # input/output: sample array, sorted into # ascending order on output real brr[*] # input/output: second array int n # number of samples int i, j real a, b #============================================================================== begin do j = 2, n { a = arr[j] b = brr[j] do i = j-1, 1, -1 { if (arr[i] <= a) goto 10 arr[i+1] = arr[i] brr[i+1] = brr[i] } i = 0 10 arr[i+1] = a brr[i+1] = b } end