I want to sort a set of IPv6 addresses based on the nth column of the address.
Specifically they're stored in a file. If I have a file with these lines...
5128581|::|2001:4:ffff:ffff:ffff:ffff:ffff:ffff||1
2747125|2001:6::|2001:5:0:ffff:ffff:ffff:ffff:ffff||2
745044|2001:5:1::|2001:5:1:ffff:ffff:ffff:ffff:ffff||3
I'd like to sort them by the 2nd column to get the following output:
5128581|::|2001:4:ffff:ffff:ffff:ffff:ffff:ffff||1
745044|2001:5:1::|2001:5:1:ffff:ffff:ffff:ffff:ffff||3
2747125|2001:6::|2001:5:0:ffff:ffff:ffff:ffff:ffff||2
How can I do that?
I've found some useful questions about this (Sort a file by first (or second, or else) column in python, Sorting IP Addresses in a Python Script) but I can't figure this out.