Heap Sort is a comparison-based sorting algorithm that uses a binary heap data structure to sort an array in ascending or descending order. The binary heap is a complete binary tree that satisfies the heap property, which states that the value of each node is greater than or equal to (in a max heap) or less than or equal to (in a min heap) the values of its children.

Here are the steps to perform Heap Sort:

1. Build a max heap or min heap from the input array, depending on whether you want to sort the array in ascending or descending order.
To build a max heap:

    - Start with the first non-leaf node (i.e., the parent of the last leaf node) and traverse down the heap.
    - For each node, compare its value with the values of its left and right child nodes.
    - If the value of a child node is greater than the value of its parent node, swap the values.
    - Continue the traversal until you reach the root node.

2. Extract the root node from the heap and place it at the end of the array.

3. Repeat step 2 for the remaining nodes in the heap, but exclude the already sorted nodes at the end of the array.

4. After all nodes have been extracted and placed at the end of the array, the array will be sorted in ascending or descending order.

Here's a Python implementation for Heap Sort:

```py
def heapSort(array):
    n = len(array)

    # Build max heap
    for i in range(n // 2 - 1, -1, -1):
        heapify(array, n, i)

    # Extract nodes and place at the end of the array
    for i in range(n - 1, 0, -1):
        array[0], array[i] = array[i], array[0]
        heapify(array, i, 0)

    return array

def heapify(array, n, i):
    largest = i
    left = 2 * i + 1
    right = 2 * i + 2

    if left < n and array[left] > array[largest]:
        largest = left

    if right < n and array[right] > array[largest]:
        largest = right

    if largest != i:
        array[i], array[largest] = array[largest], array[i]
        heapify(array, n, largest)

print(heapSort([453, 23, 765, 3, 764])) # Prints: [3, 23, 453, 764, 765]
```

In the above code, the `heapify` function is used to maintain the heap property of the binary heap, and the swap function is used to swap the values of two elements in the array.
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence