New submission from Michał Kozik <mike.koi...@gmail.com>: Tuples (datetime, description) all are sorted by the date except one entry (2021-03-09) which is out of order:
Expected order: Actual order: 2021-03-04 Event E 2021-03-04 Event E 2021-03-07 Event B 2021-03-07 Event B 2021-03-08 Event C 2021-03-08 Event C 2021-03-09 Event A 2021-03-11 Event D 2021-03-11 Event D 2021-03-09 Event A In REPL it can be replicated by pasting the following code: import heapq from datetime import datetime event_a = (datetime.strptime('2021-03-09', '%Y-%m-%d'), "Event A") event_b = (datetime.strptime('2021-03-07', '%Y-%m-%d'), "Event B") event_c = (datetime.strptime('2021-03-08', '%Y-%m-%d'), "Event C") event_d = (datetime.strptime('2021-03-11', '%Y-%m-%d'), "Event D") event_e = (datetime.strptime('2021-03-04', '%Y-%m-%d'), "Event E") events = [] heapq.heappush(events, event_a) heapq.heappush(events, event_b) heapq.heappush(events, event_c) heapq.heappush(events, event_d) heapq.heappush(events, event_e) expected_list = [event_e, event_b, event_c, event_a, event_d] assert events == expected_list ---------- components: Library (Lib) files: test_heapq.py messages: 388012 nosy: mike.koikos priority: normal severity: normal status: open title: heapq fails to sort tuples by datetime correctly type: behavior versions: Python 3.8, Python 3.9 Added file: https://bugs.python.org/file49848/test_heapq.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43385> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com