Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac 17229 _sort_key as an hidden method
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed May 23, 2016
1 parent a7df3ea commit 916f4bf
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/sage/categories/examples/filtered_algebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,30 @@ def __init__(self, base_ring):
"""
I = IndexedFreeAbelianMonoid(['x', 'y', 'z'], prefix='U')

def sort_key(x):
return (-len(x), x.to_word_list())
CombinatorialFreeModule.__init__(self, base_ring, I, bracket=False,
prefix='',
generator_key=sort_key,
generator_key=self._sort_key,
category=FilteredAlgebrasWithBasis(base_ring))

def _sort_key(self, x):
"""
Return the key used to sort the terms.
INPUT:
x -- a basis index (here an element in a free Abelian monoid)
EXAMPLES::
sage: A = AlgebrasWithBasis(QQ).Filtered().example()
sage: S = A.an_element().support(); S
[U['x']^2*U['y']^2*U['z']^3, U['x'], 1, U['y']]
sage: [A._sort_key(m) for m in S]
[(-7, ['x', 'x', 'y', 'y', 'z', 'z', 'z']), (-1, ['x']),
(0, []), (-1, ['y'])]
"""
return (-len(x), x.to_word_list())

def _repr_(self):
"""
Return a string representation of ``self``.
Expand Down

0 comments on commit 916f4bf

Please sign in to comment.