works on displaying sorted IndexPair array