Make Tag Banner also appear on tagged topic pages

Yeah, I don’t know if it would be widely useful enough to add the features to the original plugin. A separate version or an add-on called “Tagged Topic Banner” might be more appropriate.

But I think the utility is pretty limited unless there’s also some way for the author to specify which tag will be primary. The only things I can think of are…

1.) A hack like making the alpha-sort treat a character like ~ as top-of-list.

AskBot suggested an approach for a plugin monkey-patch
# plugin.rb
after_initialize do
  module ::CustomTagSort
    def custom_tag_sort(tags)
      tags.sort_by do |tag|
        # Puts ~-prefixed tags first, then sorts A-Z
        [tag.name.start_with?("~") ? 0 : 1, tag.name.downcase]
      end
    end
  end

  # Patch into the serializer/method that computes visible_tags or similar
  require_dependency 'topic_tags_mixin'
  TopicTagsMixin.prepend(Module.new do
    private

    def all_tags
      return @tags if defined?(@tags)
      tags = topic.visible_tags(scope)
      if SiteSetting.tags_sort_alphabetically
        tags = ::CustomTagSort.custom_tag_sort(tags)
      else
        topic_count_column = Tag.topic_count_column(scope)
        tags = tags.sort_by { |tag| tag.public_send(topic_count_column) }.reverse
      end
      @tags = tags
    end
  end)
end

2.) Even better: ordering tags per a specified order of tag groups.

Searching around turns up a number of topics requesting more control over tag order, as it often matters for various reasons (genus → species, make → model, etc.) – but responses suggest it would be a fair bit of work.