How duplicate removal preserves order
If the input is red, blue, red on three separate lines, the output is red followed by blue. The first copy of each exact line stays where it first appeared relative to the other unique lines. This is useful for tidying a list of categories, labels, or URLs.
Why two matching-looking entries can remain
The comparison is exact. “Apple” and “apple” are different lines, as are words with extra trailing spaces. If capitalization and spacing shouldn’t matter for your list, normalize them before removing duplicates. To alphabetize the remaining items, send the cleaned list to the line sorter.