sort dicts and remove duplicates