-n compare according to string numerical value
-u output only the first of an equal run
...so the implementation seems clear enough. With -n the comparison is numerical, with -u lines which compare equal are deduplicated. But almost certainly not as intended!
If you want to stick with Bash then the commands split, join, cut, paste, join come in very handy.
For me there is a threshold beyond which I move to AWK. Some would prefer Perl over AWK, but I cannot hold all of Perl's syntax and keywords in my brain.
Sometimes the needed processing is either a lot for AWK, or I have to be at my best behavior -- the equivalent of meeting my girlfriend's parents for the first time. In such cases I use Python. I usually do not use Python for one offs that I do not intend to maintain because with AWK you can usually relieve yourself of the ceremony of setting up a read and tokenize loop. Then again, some prefer making a sqlite database out of the file and use SQL.
> For me there is a threshold beyond which I move to AWK. Some would prefer Perl over AWK, but I cannot hold all of Perl's syntax and keywords in my brain
You don't have to hold all of a language's syntax and keywords in your brain to use that language. Or even be aware of all the syntax and keywords.
It's fine to just learn the subset of a language needed for the things you are going to use it for.
Awk is great, but I don’t use it often enough to memorize the awk syntax. That’s why I use “pawk”, an awk-like tool with a Python syntax. It sets up the read and tokenize loop for me :)
nushell's sort and uniq do what you might expect, operating on the whole value (line). Copying the data to the clipboard (hence pbpaste; substitute if necessary):