Implemented sorting and formatted output. Will be adding unit tests later.