def _ensure_requested_network_ordering(accessor, unordered, preferred):
 if preferred:
  unordered.sort(key=(lambda i: preferred.index(accessor(i))))

def _ensure_requested_network_ordering ( accessor , unordered , preferred ) : if preferred : unordered . sort ( key = ( lambda i : preferred . index ( accessor ( i ) ) ) )
sort a list with respect to the preferred network ordering .