Question #198480

How do I implement minimum heap on date and time, e.g. 23/7/2021 23:45, 24/5/2021 22:10, 20/5/2021 20:00. To implement minimum heap on the example.


Expert's answer

from heapq import *


def HeapSort(i):
    hp = []
    for v in i:
         heappush(hp, v)
    return [heappop(hp) for j in range(len(hp))]


HeapSort(["23/7/2021 23:45","24/5/2021 22:10","20/5/2021 20:00"])
LATEST TUTORIALS
APPROVED BY CLIENTS