IP Address Sorter |
IP Address Sorter — Numeric Sort for Any IPv4 or IPv6 List
IP address sorter is a browser-based utility that extracts IPv4 (RFC 791) and IPv6 (RFC 4291)
addresses from any pasted text and returns them in correct numeric order — ascending or
descending. Unlike alphabetical text sorting, which incorrectly ranks
10.0.0.10 before 10.0.0.2, numeric IP sorting compares
each octet (IPv4) or hextet (IPv6) as an integer. Input can be a clean list or raw
log content containing mixed text — addresses are extracted automatically, deduplicated,
and sorted in a single pass.
| Property | Detail |
|---|---|
| Input format | Any text containing IPv4 or IPv6 addresses — clean list or raw log |
| IPv4 standard | RFC 791 — 32-bit dotted-decimal notation, 0–255 per octet |
| IPv6 standard | RFC 4291 — 128-bit colon-separated hexadecimal; compressed notation supported |
| Sort method | Per-octet integer comparison (IPv4); lexicographic hextet sort (IPv6) |
| Output order | IPv4 addresses listed first, IPv6 addresses below |
| Execution | Client-side JavaScript — no data transmitted or stored |
How to Use the IP Address Sorter
Sort IPv4 and IPv6 addresses from any text in correct numeric order in seconds.
Choose Sort Direction
Review Sorted Results
Copy the Output
Why Alphabetical Sorting Fails for IP Addresses
Standard text sorting treats an IP address as a string of characters. When sorting
10.0.0.2 and 10.0.0.10 alphabetically, the comparison reads
character-by-character: the first six characters are identical (10.0.0.),
then "2" is compared against "1" — and because "2" has a higher ASCII value than "1",
the address 10.0.0.2 is placed after 10.0.0.10.
This reverses their correct network order.
Numeric IP sorting resolves this by converting each octet to an integer before comparison.
Following RFC 791, each IPv4 address is a 32-bit value expressed as four decimal octets
(0–255). The sort compares octet 1, octet 2, octet 3, and octet 4 as integers in sequence.
10.0.0.2 has fourth octet = 2; 10.0.0.10 has fourth octet = 10.
Integer comparison correctly places 2 before 10.
IPv6 addresses (RFC 4291) are sorted lexicographically on their colon-separated hexadecimal
groups. Full expanded notation and compressed forms — including ::1 (loopback)
and 2001:db8::1 (documentation prefix) — are both detected and sorted.
Mixed IPv4 and IPv6 input is handled in a single pass; IPv4 results appear first,
IPv6 results below.
Command line
How to Sort IP Addresses Without an Online Tool
Command-line options for pre-cleaned lists with one IP per line:
Linux / macOS Terminal (bash/zsh)
# Sort IPv4 addresses numerically
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n ips.txt
# Sort numerically and remove duplicates
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n -u ips.txt
Windows PowerShell
# Sort IPv4 numerically using Version object octet comparison
Get-Content ips.txt | Sort-Object { [System.Version]$_ }
# Sort and remove duplicates
Get-Content ips.txt | Sort-Object { [System.Version]$_ } -Unique
Python 3 Cross-Platform (IPv4 and IPv6)
import ipaddress
with open('ips.txt') as f:
ips = [line.strip() for line in f if line.strip()]
sorted_ips = sorted(set(ips), key=lambda ip: ipaddress.ip_address(ip))
print('\n'.join(str(ip) for ip in sorted_ips))
The online tool accepts raw text with surrounding content and extracts IP addresses automatically. Command-line options require a pre-cleaned file with one address per line and do not support mixed IPv4 and IPv6 without additional scripting.
Common Uses for IP Address Sorting
Security incident response. A SOC analyst pulls source IP addresses from a SIEM alert — 300 entries in random order from raw firewall logs. Pasting the full log output into the IP Address Sorter instantly organizes the addresses numerically. Contiguous ranges become immediately visible, exposing automated scanning patterns and potential DDoS source blocks that are invisible in unsorted data.
Firewall rule audit. A network engineer exports an access control list from a router — a 500-line config dump mixing IPv4 and IPv6 permit and deny statements. Pasting the full export extracts all addresses, removes duplicates that appear in multiple rules, and sorts them numerically. Gaps in the intended address plan and overlapping ranges become immediately apparent.
Server inventory documentation. A DevOps engineer adds 60 new hosts to a server inventory spreadsheet over three months. The IP address column is out of sequence. Copying the column, sorting it in the tool, and pasting it back takes under 30 seconds — the result is a correctly ordered inventory ready for subnet documentation and DHCP static-assignment planning.