def _ip_sort(ip):
 idx = '001'
 if (ip == '127.0.0.1'):
  idx = '200'
 if (ip == '::1'):
  idx = '201'
 elif ('::' in ip):
  idx = '100'
 return '{0}___{1}'.format(idx, ip)

def _ip_sort ( ip ) : idx = '001' if ( ip == '127.0.0.1' ) : idx = '200' if ( ip == '::1' ) : idx = '201' elif ( '::' in ip ) : idx = '100' return '{0}___{1}' . format ( idx , ip )
ip sorting .