adding checks to _sortByLabel, see #603