Premium tools, free for everyone. Most run right in your browser.

OpenMultiURL

Links and URLs

How to Sort a List of URLs by Address, Domain or Path

The title How to Sort a List of URLs on a coloured card with grouped web addresses

A list can look tidy and still be sorted the wrong way. Put an HTTP address beside an HTTPS address, add a subdomain, and alphabetical order may stop matching the groups you wanted. When I explain how to sort a list of URLs, I start with what you need to do next, not with a sort button. I'll show you how I choose an order, prepare the list, and keep useful parts of each link intact.

What does sorting a list of URLs actually do?

I think of sorting as changing the order of records without changing their contents. If you give me a list of addresses, an alphabetical sort should rearrange those addresses. It shouldn't quietly remove a query, rewrite a path or decide that two different strings represent the same page.

I separate the URL from the sorting key

My sorting key is the part I compare. That can be the complete address, its hostname or its path. The MDN URL reference explains these separate components. Keeping that distinction clear helps me group links without editing the original addresses.

  • I use sorting to put related-looking addresses together for review.
  • I use duplicate removal only after deciding which differences matter.
  • I check links separately because a neat order tells me nothing about whether a page opens.

And I don't treat nearby entries as proof of duplication. A product address with a size parameter may show a different selection from the address beside it. Sorting makes that difference easier to inspect. It doesn't tell me whether I should keep or discard it.

Should I sort by full URL, domain or path?

I choose the sorting key by finishing this sentence: I want these links together because they share something. If that something is a source website, I use the hostname. If it's a folder within a site, I use the path. For a simple reference list, the complete address is usually enough.

How I choose an order for a URL list
Sorting keyWhen I use itWhat I watch
Full URLA quick alphabetical master listProtocol differences can separate related addresses
HostnameReviewing links from each source togetherSubdomains remain separate unless I choose another rule
PathComparing folders or page typesMatching paths can belong to different websites
A chosen query valueReviewing a particular filter or campaign fieldMissing values and other parameters still matter

I define what I mean by domain

For grouping, I normally mean the hostname, such as docs.example.com. I don't automatically merge that with example.com or www.example.com. Those are different hosts. The host component can also include a port, so I decide whether my task needs the hostname alone or that extra detail.

For paths across several websites, I prefer hostname as the first key and path as the next. Otherwise, unrelated pages with the same path can sit together. My goal is an order that helps you review the list, not an order that merely looks alphabetical.

Before I sort anything, I save the original list. That's especially useful if the addresses came from a spreadsheet export or copied notes. I want a way back if cleanup removes something I later need. My working copy gets the changes; my source copy stays untouched.

  • I put each complete address on its own line.
    • If a long address only wraps visually, I leave it alone.
    • If copying inserted a real line break inside an address, I repair that entry before sorting.
  • I remove empty lines and accidental spaces around addresses.
    • I don't delete characters from inside a URL just because they look unusual.
    • I check suspicious entries against the original rather than guessing.
  • I preserve any labels or notes attached to the URLs.
    • For several columns, I keep the records in a spreadsheet.
    • For a plain list, I make sure titles haven't been pasted between addresses.

I can use Text Cleaner for text cleanup, but I still inspect the result. Cleanup isn't permission to lowercase everything or strip punctuation. Encoded characters and query separators can be part of a working address, and changing them can change what the address means.

Tip from me: I keep cleanup and sorting as separate passes. If an address changes unexpectedly, that makes it much easier for me to find which step caused it.

How do I sort a list of URLs with URL Sorter?

I built URL Sorter, and I test my tools on a budget Android phone and a laptop. For a standalone list, this is where I start. I keep spreadsheets for jobs where each address has other information that needs to move with it.

  1. I open URL Sorter and paste my working list into the input, with one complete URL per line.
  2. I choose the order for the task. For a basic alphabetical list, I use ascending order of the complete addresses.
  3. I run the sort, then inspect the beginning and end of the result rather than copying it immediately.
  4. I compare any odd-looking entry with my original, especially entries containing spaces, query parameters or mixed case.
  5. I copy the result into a separate working file, keeping the source list available.

I check the order before I trust it

Suppose my example list contains https://example.com/blog/tools and https://another.example/help. For a full-address alphabetical sort, I expect the another.example address before the example.com address. I also check that the path and query text haven't changed. The useful test is both order and preservation, not appearance alone.

If what I really need is source grouping, I don't force a full-text sort to do that job. I use a hostname key in a spreadsheet instead. And I don't assume that pasting a list into URL Sorter checks destinations, detects harmful sites or confirms that every address works.

How do I sort URLs in Excel or Google Sheets?

I use a spreadsheet when URLs have titles, owners, dates or review notes beside them. My main rule is simple: sort the whole record. Sorting only the address column can leave a title attached to the wrong page, which is much harder to notice than an obviously broken link.

I keep complete rows together in Excel

In Excel, I select the complete data range, open Data, then Sort, and choose the URL column. I use A to Z for ascending text order and tell Excel if my range has headers. I check a familiar URL and its note afterward. Microsoft also warns that leading spaces can affect sorting, so I remove accidental ones first.

I use range sorting in Google Sheets

In Google Sheets, I select the complete range, choose Data, Sort range, then Advanced range sorting options. I mark Data has header row when appropriate and choose my URL column. For grouped review, I can add another sort column, such as hostname first and path next.

If I want a sorted view apart from my source, Sheets also offers the SORT function. It accepts a range, a sort column, an ascending or descending choice, and additional sort columns. I check the output area before using it so the result has room without disrupting my working layout.

How can I group URLs by domain or path?

For component-based sorting, I keep the complete URL in its original column and add helper columns. One holds the hostname; another holds the path. Then I sort the whole range using those helpers. That gives me useful grouping while preserving the address I actually need to open or share.

Example helper columns I would use for grouping
Original URLHostname keyPath key
https://example.com/helpexample.com/help
https://docs.example.com/startdocs.example.com/start
https://example.com/blog/tools?view=listexample.com/blog/tools

I use URL Parser to inspect the parts when I'm unsure where a component begins or ends. For source-focused work, Domain Extractor is also useful. I keep extracted values as helpers, not replacements for the original list.

I avoid guessing the hostname by chopping text at dots. Subdomains matter, and a host can include a port. Parsing the URL gives me a clearer basis for grouping. If extraction changes the number or order of records, I stop and reconcile them before attaching helper values to spreadsheet rows.

Tip from me: I use hostname, then path, then the original URL as successive sorting keys when I need a repeatable review order. That keeps related pages together without discarding their differences.

Should I remove duplicates or tracking parameters first?

I decide what the list is for before removing anything. A campaign review needs tracking details. A page inventory may need a separate destination-focused view. Those are different jobs, so I don't apply the same cleanup rules to both. I can sort either list without deleting parameters at all.

  • For exact repeated text, I remove repeated lines only when I don't need repeated occurrences.
  • For tracking variants, I review which parameters are genuinely tracking before removing them.
  • For different addresses that may show the same page, I investigate rather than treating similar spelling as proof.

I use URL Deduplicator as a separate cleanup step and inspect the result against my rules. Parameters may control language, pagination, filters or product variants. Removing all of them can collapse useful differences. Even repeated identical addresses may matter if my source list records separate occurrences.

I don't confuse list sorting with parameter sorting

The URL Standard's URLSearchParams sort method sorts parameter names inside a URL, not the URLs in your list. Processing parameters can also change serialization, including spaces represented as %20 becoming +. I leave parameter order and encoding alone unless changing them is an intentional, checked part of the job.

What mistakes make a sorted URL list misleading?

My least favourite cleanup advice is to make every address look the same before sorting. It sounds tidy, but it can erase real differences. I remove accidental formatting around a URL. I don't rewrite the URL itself just to make the list more uniform.

Changes I avoid making automatically
Tempting changeWhy I pauseWhat I do instead
Lowercase the whole URLPaths can be case-sensitivePreserve the original path
Remove every trailing slashSlash variants aren't automatically equivalentCheck site behaviour before merging
Replace HTTP with HTTPSThe addresses aren't automatically interchangeableCheck the destination and redirects
Remove www or other subdomainsDifferent hosts may serve different contentKeep hosts separate unless grouping is intentional
Remove every fragmentA fragment can identify a useful location within a resourceKeep it when the reference needs that location

If an alphabetical result looks unexpected, I check the comparison rules as well as the data. Ordering can depend on the software and locale. Mixed case, punctuation or a leading space can explain an apparent oddity. I compare the actual strings before deciding that the sort failed.

For apparent duplicate pages, I treat redirects and canonical signals as evidence to investigate. Google's canonicalization guidance describes consolidating duplicate or similar pages, which is a different question from whether two URL strings match. My sorted list helps me review candidates; it doesn't settle that question.

Before sharing or opening the result, I compare it with the source. If I only sorted, I expect the same records in a different order. If I also removed entries, I want to know why each kind of removal happened. I don't accept a shorter list as proof of better cleanup.

  1. I check that complete addresses survived and that spreadsheet notes still match their URLs.
  2. I inspect unfamiliar hosts and addresses containing private tokens, unpublished paths or sensitive information.
  3. I investigate malformed entries separately and check redirects where the final destination matters.
  4. I open only the group I need for the next task, rather than launching the entire list.

I don't send sensitive lists to a third-party tool unless I understand its data-handling practices. And I don't treat sorting as a malware check. An address can be perfectly formatted and still lead somewhere I shouldn't trust. Those checks need their own attention before bulk opening.

Once I've reviewed the links, I can use Open Multiple URLs for a selected group. If a link goes somewhere unexpected, I investigate with Redirect Checker. I keep that destination review separate from sorting so a tidy result never becomes a false promise that everything works.

Questions people ask

How do I sort a list of URLs alphabetically?

I put one complete URL on each line, remove accidental surrounding spaces and blank lines, then sort the full addresses in ascending order. I keep the original copy and inspect the result before saving it. If I need source grouping rather than full-text order, I choose a hostname key instead.

How can I sort URLs by domain name?

I keep the original URLs and create a separate hostname column, then sort the complete records by that column. I decide explicitly whether subdomains should stay separate. For example, docs.example.com and example.com aren't the same hostname, so I don't silently combine them just to make the list shorter.

Can I sort a URL list online for free?

Yes. I provide URL Sorter as a free option for arranging a standalone list online. I still prepare one address per line and review the output. For a list containing private access tokens or unpublished information, I first check the data-handling practices of any service I plan to use.

How do I sort a list of URLs in Excel?

I select the entire data range, including any notes or labels, then use Data and Sort to choose the URL column and ascending text order. I identify the header row correctly and check that related cells moved together. I also remove accidental leading spaces because they can affect the result.

How do I sort URLs in Google Sheets?

I select the full range and use Data, Sort range, then Advanced range sorting options. I identify the header row and choose the URL column. If I need domain grouping, I add a hostname helper column. I can also use SORT to produce a separate sorted view of my source range.

Does sorting a URL list check whether the links work?

No. I treat sorting as an ordering task, not a destination check. A sorted list can still contain malformed addresses, redirects or pages that don't open. I inspect questionable entries separately, and I don't assume a working link is safe merely because it appears in a tidy list.

What to do next

I start with an untouched copy, put one URL on each line, and choose the order that matches my next task. For a quick alphabetical list, you can open URL Sorter, paste your working copy and review the sorted result before saving it. If your links have notes beside them, keep the complete rows together in a spreadsheet instead. Then make a separate decision about duplicates, tracking parameters and destination checks. My aim isn't to make every address look alike. It's to give you a useful order without losing information you may need later.

Sources I checked

Tools from this guide

Keep reading