Any idea what lexicographic order means in the Symbolic Toolbox? I mean, what are the "alphabet" and "word" definitions that lexicographically define all things the toobox supports, like sybolic constants, variables, expressions, etc. The doc page under the "Input Arguments" section does define some rules for specific cases, but in the most general case it just says: "Therefore, sort uses internal sorting rules to optimize its performance."
To sort the symbolic array numerically, you can convert the symbolic expressions to their numerical equivalents before sorting. Here's how you can do it:
Convert the symbolic expressions to numerical values.
Sort the numerical values.
Recreate the sorted symbolic array using the indices from the sorted numerical values.
Please refer to the following code snippet to implement the same:
a = sym.empty();
a = [a, 0, pi, pi/2, -pi/2, pi/4];
a = sym(a); % Ensure the array is symbolic
% Convert to numerical values
num_a = double(a);
% Sort the numerical values and get the sorting indices
[sorted_num_a, sort_idx] = sort(num_a);
% Recreate the sorted symbolic array using the indices
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.