Python: sort an array of dictionaries with custom comparator?,"key = lambda d: (not 'rank' in d, d['rank'])"