Video Coming Soon...
52: sort, and uniq
WARNING: This is from the Go course but I'm rewriting the code and the description to fit C. If you want to attempt it go ahead. The challenge is the same, just no examples yet.
The sort and uniq commands go together like peanut butter and chocolate. The sort command takes its input and sorts it, then writes the sorted version to the output. The uniq command takes a sorted input stream and prints only the unique elements.
Can you think of a reason why uniq only works on sorted input?
The Challenge
When implementing sort you'll have to implement the -f (ignore case) and -n (numeric) options. You'll also be required to use the slices package. The documentation is here:
For uniq you'll also be required to implement the -i (ignore case) and c (count occurrence). If your input is sorted then uniq doesn't need the slices package. The documentation for uniq is:
You can implement a version of uniq that doesn't need sorted input, but that version would need to use memory to remember what lines its seen and...it's very complicated.
Register for From Impostor to Programmer
Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.