Added sorting to TermUtil methods.