/* NetRexx */ options replace format comments java crossref savelog symbols /*REXX program to sort an interesting integer list.*/ bell = '1 1 2 5 15 52 203 877 4140 21147 115975' /*some Bell numbers.*/ bern = '1 -1 1 0 -1 0 1 0 -1 0 5 0 -691 0 7 0 -3617' /*some Bernoulli num*/ perrin = '3 0 2 3 2 5 5 7 10 12 17 22 29 39 51 68 90' /*some Perrin nums. */ list = bell bern perrin /*combine the three.*/ size = list.words a = 0 loop j = 1 for size a[j] = list.word(j) end j say ' as is='list a[0] = size esort(a, size) bList = '' loop j = 1 for size bList = bList a[j] end j blist = bList.strip say ' sorted='bList return /*----------------------------------ESORT subroutine--------------------*/ method esort(a, size) public static --esort: procedure expose a.; h = a[0] loop while h > 1 h = h % 2 loop i = 1 for a[0] - h j = i k = h + i loop while a[k] < a[j] t = a[j] a[j] = a[k] a[k] = t if h >= j then leave j = j - h k = k - h end end i end return