Implementation for minElementPair() and maxElementPair(). Testing still needs to be done.