Your solution doesn't do the same thing, though. His code doesn't sort.
Arguably your solution is still different because you sort the input instead of the output, but that's unlikely to matter here.
Although FWIW I just checked and the `sort` tool actually has a flag for uniquing during the sort. I don't know if that's portable though.