Pike v8.1 release 6

Method ADT.CritBit.sort_ipv4()


Method sort_ipv4

array(string) sort_ipv4(array(string) a, array ... data)

Description

Sorts an ARRAY OF IPv4-Adresses (and optional netmasks) given in dotted decimal representation with the /23 netmask notation.

Example
> array(string) a = ({ "127.0.0.121",
>	 "127.0.0.0/16",
>	 "127.0.0.1/8",
>	 "127.0.0.0/8",
>	 "128.0.0.0/1",
>	 "192.168.21.3",
>	 "8.8.8.8" });
> write("%O\n", CritBit.sort_ipv4(a));
({ /* 7 elements */
	"8.8.8.8",
	"127.0.0.0/8",
	"127.0.0.0/16",
	"127.0.0.1/8",
	"127.0.0.121",
	"128.0.0.0/1",
	"192.168.21.3"
})