Question: how to make sort work with alias?

Here is the problem. I am trying to use sort() to make solution to ode show up with constant of integrations _C1 at the front of the term, instead of how Maple shows it, which is after the term, which does not look good.

As recommened in  Why-Maple-Refuses-To-Change-Location

sort() works well. Except for this: I am also using alias for the constant of integrations, to get nicer Latex output, as recommended in earlier post (which I can't find now). 

But once I use alias, now sort no longer produce the result I want. Here is an example

restart;
sol:=dsolve(diff(y(x),x) = x+y(x),y(x));
sort(sol)

Here sort works. It moved the term with constant of integration to the front, and _C1 at front, which is what I want as it looks more clear.

But when I do 

restart;
alias(seq(c[k]=_C||k,k=0..10)):
sol:=dsolve(diff(y(x),x) = x+y(x),y(x));
sort(sol)

This is because, I am assuming, the order of _C1 is higher than c[1] and sort is using the alias of _C1 to sort on and not _C1 itself.

The only reason I am using alias, is to get nicer Latex output when converting the solution to Latex vs. when using _C1

Is there a way to tell sort to treat c[1] as _C1, and c[2] as _C2, etc...  in terms of lexicographical ordering?

I see an order option for the command sort() in help, but so far did not know how to use it for the above purpose. This only affects _C1,_C2,_C3,_C4,.. and nothing else and I only use sort() on the output of the solution of ode. May be I need to write an order function and in there tell it c[1] has same order as _C1? But _C1 has c[1] as alias? so I do not think this will not work.

Basically I want to use the alias, but also use sort() on the result as if these constants of integrations where _C1,_C2, etc..

in my code, I set the alias at the global level, before I call any function in my package.

Any ideas how to do this or workaround this?

Maple 2020.2 on windows

 

Please Wait...