Why does this test against sort | uniq | sort? It’s kind of weird to sort twice no?
$ echo c a b c | tr ' ' '\n'
c
a
b
c
$ echo c a b c | tr ' ' '\n' | sort
a
b
c
c
$ echo c a b c | tr ' ' '\n' | sort | uniq -c
1 a
1 b
2 c
$ echo c a b c | tr ' ' '\n' | sort | uniq -c | sort -rn
2 c
1 b
1 a sort | uniq -c | sort -n
The second sort is sorting by frequency (the count output by `uniq -c`).