I'm using a Heapq to store expanded nodes during search in lower cost order. frontier_test = [] heapq.heappush(frontier_test, (9, ((8, 1)))) heapq.heappush(frontier_test, (13, ((8, 3)))) heapq.heappush(frontier_test, (10, ((6, 2)))) self._logger.debug(f'frontier test : {frontier_test}') frontier test : [(9, (8, 1)), (13, (8, 3)), (10, (6, 2))] I thought it would be store in order(which I desire to be stored), [(9, (8, 1)), (10, (6, 2)), (13, (8, 3))] by comparing the first value 9, 10, 13 but it dosen't. How should I use heapq for my desired output? Continue reading...