I have a list of variables, both constant and functions of an independent variable, including derivatives. I'd like to sort these by the variable name, rather than the derivative order. For example, the default Sort gives:
Sort[{x[t], x'[t], x''[t], y[t], y'[t], y''[t],a}]
{a, x[t], y[t], x'[t], y'[t], x''[t], y''[t]}
whereas I'd like to have all the derivatives of one variable clustered together:
{a, x[t], x'[t], x''[t], y[t], y'[t], y''[t]}
I'm sure there is a way to write an ordering function to do this, but I can't figure out how to do it.
SortBy[]
ought to work… $\endgroup$