You can start from here:
<script type="text/discourse-plugin" version="1.4.0">
api.modifyClass("component:topic-list", {
pluginId: "returnTopicList",
didInsertElement: function() {
this._super();
console.log(this.topics);
}
});
</script>
This will output the list of the topics as well as their attributes (including tags).
Then I suppose you just need to juggle a bit with the array to achieve what you want.