Skip to content

Instantly share code, notes, and snippets.

@curipha
Created May 23, 2017 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curipha/1e6cc8ff46357732fe51e787d9f3ce65 to your computer and use it in GitHub Desktop.
Save curipha/1e6cc8ff46357732fe51e787d9f3ce65 to your computer and use it in GitHub Desktop.
Sort the list of FQDN (e.g. www.example.com)
#!/usr/bin/env ruby
fqdn = []
while STDIN.gets
fqdn << $_.strip
end
def s(l)
return l.split('.').reverse.join('.')
end
puts fqdn.sort {|a, b| s(a) <=> s(b) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment