(* Compare the sum of two tuples *) let compare_sum (a1,a2) (b1,b2) = if a1 + a2 = b1 + b2 then 0 else if a1 + a2 < b1 + b2 then -1 else 1 ;; (* Sort a list of tuples of 2 ints by the sum of the values*) let sort_sum l = List.sort compare_sum l ;;