'Sorts IP addresses (or partial addresses) in a numerical fashion per-octet or quartet'

def __ip_sort(self, ips):

    quartets = []
    octets = []
    for each_ip in ips:
        if (':' in each_ip):
            quartets.append([int(i, 16) for i in each_ip.split(':')])
        else:
            octets.append([int(i) for i in each_ip.split('.')])
    quartets.sort()
    quartets = map((lambda x: [format(i, '04x') for i in x]), quartets)
    octets.sort()
    octets = map((lambda x: [str(i) for i in x]), octets)
    return (['.'.join(i) for i in octets] + [':'.join(i) for i in quartets])
