As suspected by David Dai and cas the two lines are in fact different, but the only difference is in invisible characters.
Your file is a Windows text file. In a Windows text files, lines are separated by the two-character sequence CR, LF (carriage return, line feed). In a Unix text file, lines are terminated by a LF (line feed, also known as newline) character.
cat -A shows a CR as
^M and a line feed as
$ followed by a line break.
When a Windows text file is processed by a Unix utility, the Unix utility sees an extra CR character at the end of every line. As far as Unix utilities are concerned, CR is just an ordinary character; a line with a CR at the end is different from a line that's identical except for the lack of a CR at the end. Furthermore, on Windows, the newline sequence is a separator, so there is no CR, LF at the end of the file. But on Unix, a text file always ends with a LF character unless it's empty. So when you process a Windows text file with a Unix utility, what the Unix utility sees is a file with CR at the end of every line (because CR characters aren't part of the Unix encoding of a newline), and some trailing text that isn't part of a line (because of the lack of a newline at the end).
Unix text utilities differ in what they do when their input is not a valid text file due to the lack of a final newline. GNU utilities — which is what you'll find on non-embedded Linux and on Cygwin — strive to treat such files as text file and preserve the lack of a final newline. The
sort command shuffles lines around, and while it does process an unfinished input line, it always emits a newline at the end of the output. Thus to the
sort command what you have looks like a bunch of lines, each of which ends with the character CR, except the last input line which doesn't end with CR. In the output, all the lines end with CR except that one line that corresponds to the last input line.
uniq sees a bunch of lines that end with
brave! and a CR, and retains only one of them. It also sees one line that ends with
brave! but no CR, which it dutifully emits since that line differs from every other line.
When you print out the output on the terminal, a CR character instructs the terminal to move the cursor to the beginning of the current line; a LF character instructs the terminal to move the cursor to the beginning of the next line. Thus the sequences LF and CR,LF are not visually distinguishable, and you see two identical-looking lines. The command
cat -A adds printable characters to make them distinct.