rewrote comparator for sum to use the library