I find a simplest way to do that, but not sure whether it works or not.
result = df.orderBy(col("score").desc(), col("id1").asc(), col("id2").asc()).dropDuplicates(["id2", "score"]).drop("score").select('id1', 'id2').dropDuplicates(["id1"]).dropDuplicates(["id2"])