Question bank › Sorting
Dsa Sorting Easy

IP Address Sorting

You have a list of IP addresses which you need to sort in ascending numerical order. Each IP address consists of four octets separated by dots. Write a program to sort the list of IP addresses numerically. Input: - The first line contains an integer p (1 ≤ p ≤ 100), the number of IP addresses. - The next p lines each contain one IP address in the standard dotted-decimal format. Output: - Print the sorted list of IP addresses, one per line. Example: Input: 3 192.168.1.1 10.0.0.1 172.16.0.1 Output: 10.0.0.1 172.16.0.1 192.168.1.1

Key concepts

sortingstringsnetworking

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.