Your specification is a bit faint. Will your input file be one line only, will your IDs always be seven alphanumeric chars, and the like. Nevertheless, try
A missing part of the requirement was whether the data could be case-converted to all lower or all upper. The sort options can ignore case but preserve it. So, if a duplicated ID is always uppercase, it is still uppercase on the output.