PHP Array Exercises : Function to sort subnets
21. Sort Subnets
Write a PHP function to sort subnets.
Sample Solution:
PHP Code:
Output:
Array ( [0] => 122.169.15 [1] => 192.167.11 [2] => 192.167.12 [3] => 192.167.16 [4] => 192.168.13 [5] => 192.169.12 [6] => 192.169.14 )
Flowchart:

For more Practice: Solve these Related Problems:
- Write a PHP script to sort an array of subnet addresses numerically by converting each subnet to its decimal equivalent.
- Write a PHP function to compare subnet strings and order them based on network address and mask.
- Write a PHP program to parse a list of subnet notations, sort them, and then display them in ascending network order.
- Write a PHP script to implement a custom sort algorithm that arranges subnets by their starting IP addresses using bitwise operations.
Go to:
PREV : Sort Array by Priority List.
NEXT : Sort Array by Day and Username.
PHP Code Editor:
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.