Skip to content

Instantly share code, notes, and snippets.

@kd7lxl
Created August 22, 2018 15:10
Show Gist options
  • Save kd7lxl/904b0c18002f8322098f056f375c3bcf to your computer and use it in GitHub Desktop.
Save kd7lxl/904b0c18002f8322098f056f375c3bcf to your computer and use it in GitHub Desktop.
Sorts a list of hostnames by their domain
#!/usr/bin/env python
import fileinput
print "".join(sorted(fileinput.input(), key=lambda fqdn: fqdn.lower().split('.')[::-1])),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment