Skip to content

Instantly share code, notes, and snippets.

@michaelBenin
Created July 20, 2014 21:48
Show Gist options
  • Save michaelBenin/0889a18defeee7c9b15e to your computer and use it in GitHub Desktop.
Save michaelBenin/0889a18defeee7c9b15e to your computer and use it in GitHub Desktop.
Sort requirements pip files or requirements.txt for python dependencies
requirements_file = 'base.pip'
requirements = open(requirements_file, 'r')
content = requirements.read().splitlines()
content = list(set(content))
content.sort(key=lambda y: y.lower())
content = '\n'.join(content)
file = open('sorted_'+requirements_file, 'w')
file.write(content)
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment