Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个类似的清单
L = [0-4, 0-3, 3-5, 1-2]
我想按键和值对列表进行排序,结果是
L = [0-3, 0-4, 1-2, 3-5]
我找到了keysort,但它只按 key 排序。我可以自己编写排序,但我需要一个有效的解决方案。
调用 sort/2 (或 msort/2 如果你想保留重复)
?- sort([0-4, 0-3, 3-5, 1-2], S). S = [0-3, 0-4, 1-2, 3-5].