Assuming a text file is present:
10 A QAZ
5 A EDC
14 B RFV
3 A WSX
7 B TGB
I want to sort it with the second column as the primary column with alphabetical order and the first column as the secondary column with numerical order. Below is the expected result:
3 A WSX
5 A EDC
10 A QAZ
7 B TGB
14 B RFV
I tried sort -k 2,2 -k 1,1 a.txt -nand sort -k 2,2 -k 1,1 a.txt, but both of them gave the wrong results. What should I solve this problem? Thank.
source
share