Sorting algorithms/Heapsort: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
(→{{header|J}}: reduce to one (0,])) |
||
Line 466: | Line 466: | ||
if. 1>: c=. # y do. y return. end. |
if. 1>: c=. # y do. y return. end. |
||
z=. (] siftDown ~c,~[)&.>/ (<y),~]&.>i.1+<.-:c-2 NB. heapify |
z=. (] siftDown ~c,~[)&.>/ (<y),~]&.>i.1+<.-:c-2 NB. heapify |
||
> (( |
> (](] siftDown {`(|.@[)`]}~) 0,[)&.>/ z,~]&.>1+i.c-1 |
||
)</lang> |
)</lang> |
||
'''Examples''' |
'''Examples''' |