Created
September 2, 2011 10:47
-
-
Save ekohl/1188364 to your computer and use it in GitHub Desktop.
Sort domain names by their extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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