Skip to content

Instantly share code, notes, and snippets.

@ekohl
Created September 2, 2011 10:47
Show Gist options
  • Select an option

  • Save ekohl/1188364 to your computer and use it in GitHub Desktop.

Select an option

Save ekohl/1188364 to your computer and use it in GitHub Desktop.
Sort domain names by their extension
#!/usr/bin/env python
import sys
domains = sys.stdin.read().split()
domains = sorted(list(reversed(domain.split("."))) for domain in domains)
domains = [ ".".join(reversed(domain)) for domain in domains ]
print "\n".join(domains)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment