Python Sorted Time Complexity