How to sort IP addresses

Use sort utility to sort IP addresses.

List IP addresses.

$ cat ip_file
10.0.0.2
10.3.0.1
192.168.0.3
192.168.9.11
192.168.9.10
10.2.2.1
10.2.2.21
10.2.2.17
192.168.2.1
10.0.0.1
10.0.0.100

Sort IP addresses.

$ sort -t. +0n -1n +1n -2n +2n -3n +3n ip_file
10.0.0.1
10.0.0.2
10.0.0.100
10.2.2.1
10.2.2.17
10.2.2.21
10.3.0.1
192.168.0.3
192.168.2.1
192.168.9.10
192.168.9.11