fix #6570: use treeMap for getKeyLabelPairs() to sort the ranks