You need to construct your function sortGT
, so that it compares pairs the way you want it:
sortGT (a1, b1) (a2, b2)
| a1 < a2 = GT
| a1 > a2 = LT
| a1 == a2 = compare b1 b2
Using this you get the following results (I used ghci):
*Main Data.List> sortBy sortGT [(1, "b"), (1, "a"), (2, "b"), (2, "a")]
[(2,"a"),(2,"b"),(1,"a"),(1,"b")]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…