Sorting algorithms/Heapsort: Difference between revisions
Content added Content deleted
(→{{header|Groovy}}: new solution) |
|||
Line 795: | Line 795: | ||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
Loose translation of the pseudocode: |
Loose translation of the pseudocode: |
||
<lang groovy>def makeSwap = { a, i, j -> print "."; |
<lang groovy>def makeSwap = { a, i, j = i+1 -> print "."; a[[j,i]] = a[[i,j]] } |
||
def checkSwap = { |
def checkSwap = { list, i, j = i+1 -> [(list[i] > list[j])].find{ it }.each { makeSwap(list, i, j) } } |
||
def siftDown = { a, start, end -> |
def siftDown = { a, start, end -> |