Only preventDefault click if sort is performed

Otherwise we risk breaking behaviour for other anchors in the
heading element.