func (p *PriorityQueue) Pop() interface{} { n := p.Len() p.Swap(0, n-1) heap.Down(p, 0, n-1) val := p.List[n-1] p.List = p.List[0 : n-1] return val }
func heapSort(a []int) { arr := Array(a) heap.Init(arr) for i := len(arr) - 1; i > 0; i-- { arr.Swap(0, i) heap.Down(arr, 0, i) } }