Add function to sort selected words.