commander: improve sorting algorithm

These changes give higher scores for whole words matches and basename matches, which should improve overall sorting.

It also adds some disabled debug code to ease further development of the sort algorithm.