Python heapq vs. sorted complexity and performance
I'm relatively new to python (using v3.x syntax) and would appreciate notes regarding complexity and performance of heapq vs. sorted. I've already implemented a heapq based solution for a greedy 'find the best job schedule' algorithm. But then I've learned about the possibility of using 'sorted' together with operator.itemgetter() and reverse=True. Sadly, I could not find any explanation on expected complexity and/or performance of 'sorted' vs. heapq. If you use binary heap to pop all elements in order, the thing you do is basically heapsort . It is slower than sort algorightm in sorted