Alphabetically ordered output flag
Requesting a flag to generate requirements.txt in deterministic order for easier reviews / diffs
https://github.com/bndr/pipreqs/issues/133
+1. Is it furthermore feasible to make that a default?
First, it would be good to add the word 'sort' somewhere in the title of this issue so it's easier to find. I wanted to raise the same thing because it's a pain to have complex diffs when committing requirements.txt updates to repos.
To do this, I think all that's needed is in pipreqs/pipreqs.py generate_requirements_file() the file write could become:
output_lines = sorted([fmt.format(**item) if item['version'] else '{name}'.format(**item) for item in imports]) out_file.write('\n'.join(output_lines) + '\n')
If there's currently no defined behaviour for the order, I'd avoid making it an option, seems like unnecessary complexity.
Obviously you'd also need to write a test and update the docs.