`(-)` is wrong for comparing integers because of overflows. You should either use `compare`, or explicitly `if x < y then -1 else if x > y then 1 else 0`, or take another example. One reasonable should would be a pair of integers (or some other ground type): it lets you define the lexicographic ordering (while `compare`'s behavior is not specified).