Created
August 16, 2025 16:53
-
-
Save jimdiroffii/f7b6bec5e892d95c9ce43012498f95f2 to your computer and use it in GitHub Desktop.
Sort a list of IP addresses using Python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data = ["1.2.3.4", "1.1.1.1"] | |
| data.sort(key=lambda ip: [int(part) for part in ip.split('.')]) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sort IPs from a file: