First arrange in reverse order in the second column to ensure that the numbers are output from large to small, and then use awk. Only the string in the first column will be output when it appears for the first time, and the others will be discarded. This should solve the problem. Problem. However, this method may cause awk to occupy a lot of memory, which may cause problems if the file is too large.
Method 2
rrreee
This solution is to sort by the first column, and then use awk to filter the results. The filtering process is equivalent to an enhanced version of uniq. This solution is much better in terms of memory usage, but the amount of code is slightly larger and not very concise.
Method 1
First arrange in reverse order in the second column to ensure that the numbers are output from large to small, and then use awk. Only the string in the first column will be output when it appears for the first time, and the others will be discarded. This should solve the problem. Problem. However, this method may cause awk to occupy a lot of memory, which may cause problems if the file is too large.
Method 2
rrreeeThis solution is to sort by the first column, and then use awk to filter the results. The filtering process is equivalent to an enhanced version of uniq. This solution is much better in terms of memory usage, but the amount of code is slightly larger and not very concise.
Reverse order, reverse the first and second columns, remove duplicates by the second column, reverse the first and second columns
Put the first column into the array and then compare the values in the array and replace the larger value with the new value