Changed the tags map logic to sort the tags based on the frequency and then by tag name