Sorting and counting
sortputs lines in order:-rreverses it, and-nsorts by number instead of by text.uniqcollapses adjacent duplicate lines, and-ccounts them.
That word adjacent matters. uniq only compares each line with the one right before it, so you nearly always sort first:
Real world: sort | uniq -c is the shell's GROUP BY. It's how you count visitors per IP, errors per type, or commits per author.