Skip to content

Change Symbol order to have uppercase names before lowercase ones.#1680

Closed
hrueter wants to merge 2 commits intoMathics3:masterfrom
hrueter:alph_canonical_ordering
Closed

Change Symbol order to have uppercase names before lowercase ones.#1680
hrueter wants to merge 2 commits intoMathics3:masterfrom
hrueter:alph_canonical_ordering

Conversation

@hrueter
Copy link
Contributor

@hrueter hrueter commented Feb 5, 2026

Having uppercase names before lowercase ones is the canonical order in WL as defined by the sort function.
https://reference.wolfram.com/language/ref/Sort.html

@hrueter hrueter force-pushed the alph_canonical_ordering branch from 3df094f to 7935c97 Compare February 5, 2026 16:51
Monomial({str.swapcase(self.name): 1}),
0,
self.name,
str.swapcase(self.name),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, this is trickier: In WMA,

In[1]:= Sort[{a,b,A,B}]                                                         

Out[1]= {a, A, b, B}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reproduce it, try to concatenate name.
lowercase() with the swapcase()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reproduce it, try to concatenate name.
lowercase() with the swapcase()

@hrueter hrueter force-pushed the alph_canonical_ordering branch from 7935c97 to 61cbf57 Compare February 6, 2026 15:10
else BASIC_EXPRESSION_ELT_ORDER
),
Monomial({self.name: 1}),
Monomial({str.lower(self.name): 1}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Monomial({str.lower(self.name): 1}),
Monomial({self.name.lower()+self.name.swapcase(): 1}),

Monomial({self.name: 1}),
Monomial({str.lower(self.name): 1}),
# The canonical in for WL is to sort by lowercase first. Hence we must swap the case.
Monomial({str.swapcase(self.name): 1}),
Copy link
Contributor

@mmatera mmatera Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Monomial({str.swapcase(self.name): 1}),

Monomial({str.swapcase(self.name): 1}),
0,
self.name,
str.lower(self.name),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
str.lower(self.name),
self.name,

@mmatera
Copy link
Contributor

mmatera commented Feb 9, 2026

@hrueter, shall we close this one in favor of #1685 then?

@hrueter hrueter closed this Feb 9, 2026
@hrueter hrueter deleted the alph_canonical_ordering branch February 9, 2026 17:25
mmatera added a commit that referenced this pull request Feb 9, 2026
@hrueter, this is a proposal for the reimplementation #1680, for taking
into account the WMA alphabetic ordering. Thanks for noticing this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants