def _sort_factors(factors, **args):
 def order_if_multiple_key(factor):
  (f, n) = factor
  return (len(f), n, f)
 def order_no_multiple_key(f):
  return (len(f), f)
 if args.get('multiple', True):
  return sorted(factors, key=order_if_multiple_key)
 else:
  return sorted(factors, key=order_no_multiple_key)

def _sort_factors ( factors , ** args ) : def order_if_multiple_key ( factor ) : ( f , n ) = factor return ( len ( f ) , n , f ) def order_no_multiple_key ( f ) : return ( len ( f ) , f ) if args . get ( 'multiple' , True ) : return sorted ( factors , key = order_if_multiple_key ) else : return sorted ( factors , key = order_no_multiple_key )
sort low-level factors in increasing complexity order .