check if tuple is sorted in python