So if I wanted to organize a list of websites alphabetically, and there were all of this form: example1.com, test.com, stackoverflow.com, google.com, it would be easy. However, I want to also organize subdomains. Consider the following three domains:
a.domain.com
domain.com
anotherdomain.com
If I handed them over to software to alphabetize, they would be alphabetized like this:
a.domain.com
anotherdomain.com
domain.com
However, this is not how I want them alphabetized. I want them to be alphabetized by domain, and then by subdomain as a "tiebreaker," in other words, like this:
anotherdomain.com
domain.com
a.domain.com
Could someone tell me how to code PHP (or JavaScript) to do this? (You can assume that each "website" is on a fresh line of code.)