adding sortedTriples