I want to sort some exponential numbers like {2^2,3^3,4^2} and i want The result {2^2,4^2,3^3}. But Mathematica Sort function apply's the powers in the result and return's {4,16,27}. How can i get the result in the same form as input?
1 Answer
$\begingroup$
$\endgroup$
1
All credits goes to J. M.'s technical difficulties♦
The trick is to use the Inactivate function to prevent Mathematica to apply the powers.
Inactivate[{2^2, 3^3, 4^2}, Power]
Then use SortBy function to compare the Active forms of the elements.
SortBy[Inactivate[{2^2, 3^3, 4^2}, Power], Activate]
Result:
{2^2,4^2,3^3}
-
1$\begingroup$ Well-done! $\phantom{}$ $\endgroup$ Commented May 13, 2020 at 0:01
SortBy[Inactivate[{2^2, 3^3, 4^2}, Power], Activate]
? $\endgroup$