@@ -1237,8 +1237,8 @@ cdef class BasisExchangeMatroid(Matroid):
12371237 Return the Whitney numbers of the second kind of the matroid.
12381238
12391239 The Whitney numbers of the second kind are here encoded as a vector
1240- `( W_0, ... , W_r) `, where `W_i` is the number of flats of rank `i`, and
1241- `r` is the rank of the matroid.
1240+ `( W_0, \l dots , W_r) `, where `W_i` is the number of flats of rank `i`,
1241+ and `r` is the rank of the matroid.
12421242
12431243 OUTPUT: a list of integers
12441244
@@ -1949,15 +1949,16 @@ cdef class BasisExchangeMatroid(Matroid):
19491949 sage: M._weak_invariant() == N._weak_invariant()
19501950 False
19511951 """
1952+ from sage.matroids.utilities import cmp_elements_key
19521953 if self ._weak_invariant_var is None :
19531954 if self .full_rank() == 0 or self .full_corank() == 0 :
19541955 self ._weak_invariant_var = 0
19551956 self ._weak_partition_var = SetSystem(self ._E, [self .groundset()])
19561957 else :
19571958 k = min (self .full_rank() - 1 , 2 )
19581959 fie, f_vec = self ._flat_element_inv(k)
1959- self ._weak_invariant_var = hash (tuple ([tuple ([(f, len (fie[f])) for f in sorted (fie, key = str )]), f_vec]))
1960- self ._weak_partition_var = SetSystem(self ._E, [fie[f] for f in sorted (fie, key = str )])
1960+ self ._weak_invariant_var = hash (tuple ([tuple ([(f, len (fie[f])) for f in sorted (fie, key = cmp_elements_key )]), f_vec]))
1961+ self ._weak_partition_var = SetSystem(self ._E, [fie[f] for f in sorted (fie, key = cmp_elements_key )])
19611962 return self ._weak_invariant_var
19621963
19631964 cpdef _weak_partition(self ) noexcept:
0 commit comments