Two sum problem sorting implementation