Oct-21-2017, 04:51 AM
A list to test would make it easier.
Here something I threw together. Might get you started.
Here something I threw together. Might get you started.
ip_address = [ '192.168.0.1', '192.168.0.5', '20.101.24.5', '101.17.31.8', '41.37.101.40', '41.37.101.4' ] def sort_ip(key): if key.count('.') == 3: return 4, [k.rjust(3) for k in key.split('.')] else: # need more data for dealing with ipv6 address return 6, [k.rjust(4) for k in key.split(':')] def main(): ip_address.sort(key=sort_ip) for ip in ip_address: print(ip) main()
99 percent of computer problems exists between chair and keyboard.