Sorting Using Lambda Function In Python With If Statement