Hello! I've got a list of IP addresses, each of them is prepended by its frequency counter (please find attached in the file list-1.txt). I need to sort them from most frequent to least. I tried using this command: sort -t '.' -n -k 1.1,1.8r -k 1.9 -k 2,2 -k 3,3 -k 4,4 list-1.txt But I've got some weird results.
Ok, I merged these counters with IP addresses using awk (file list-2.txt). Now they use the same separator and I can simplify the command: sort -t '.' -n -k 1,1r -k 2,2 -k 3,3 -k 4,4 -k 5,5 list-2.txt > sorted-a.txt It looks like as sorted properly but some entries with the counters 13 and 10 are misplaced. Strangely enough, when I use direct order, they are sorted correctly: sort -t '.' -n -k 1,1 -k 2,2 -k 3,3 -k 4,4 -k 5,5 list-2.txt > sorted-b.txt Is it a bug or I'm doing something wrong? I checked this in Ubuntu 22.04, sort version is 8.32. -- Best regards, Oleg Moiseichuk
2 80.94.160.207 1 80.94.166.175 5 80.94.167.87 10 80.94.171.122 3 80.94.174.76 7 80.94.174.82 1 80.94.174.86 1 80.94.174.90 13 80.94.174.97 2 95.130.87.7
2.80.94.160.207 1.80.94.166.175 5.80.94.167.87 10.80.94.171.122 3.80.94.174.76 7.80.94.174.82 1.80.94.174.86 1.80.94.174.90 13.80.94.174.97 2.95.130.87.7
7.80.94.174.82 5.80.94.167.87 3.80.94.174.76 2.80.94.160.207 2.95.130.87.7 13.80.94.174.97 10.80.94.171.122 1.80.94.166.175 1.80.94.174.86 1.80.94.174.90
1.80.94.166.175 1.80.94.174.86 1.80.94.174.90 2.80.94.160.207 2.95.130.87.7 3.80.94.174.76 5.80.94.167.87 7.80.94.174.82 10.80.94.171.122 13.80.94.174.97