Tuple Sort In Python Time Complexity