Company: Walmart_12march
Difficulty: medium
Tag Sort Problem Description You are given a linked list where each node has three attributes: tagname: A single character representing the tag name. number: An integer associated with the tag. next: A reference to the next node in the list. Your task is to sort the linked list based on the following criteria: Primary criterion: Sort the nodes by their tagname in alphabetical order. Secondary criterion: If two nodes have the same tagname, sort them by their number in ascending order. After sorting the linked list, print the elements of the sorted list. Input Format The first line of input contains an integer N: the size of linked list. The next N lines each contain two space-separated elements: representing a character 'tagName' and an integer 'number' as linked list element. Output Format Print N lines, where each line contains two space-separated elements: the 'tagname' and 'number', representing the sorted linked list. Examples Example 1: Input: 4 b 3 a 1 b 1 a 2 Output: a 1 a 2 b 1