# What is the meaning of 'internal sorting rules' in 'sort' in Symbolic Math Toolbox?

1 vue (au cours des 30 derniers jours)
Songbai Jin le 28 Avr 2022
Commenté : Songbai Jin le 6 Mai 2022
A = [factorial(sym(1001)), exp(sym(1)) + factorial(sym(1000))]
[r,s] = sort(A)
Obviously, A(1) > A(2). However, the output is
r =
[factorial(1001), exp(1) + factorial(1000)]
s =
1 2
which is quite confusing.
I notice in sort, it is mentioned that
• If X contains symbolic irrational numbers, expressions, and functions, comparing and sorting the elements can be computationally complex. Therefore, sort uses internal sorting rules to optimize its performance.
What is the meaning of 'internal sorting rules' ?
Thank you very much!
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

David Hill le 6 Mai 2022
A = [factorial(sym(1001)), exp(sym(1)) + factorial(sym(1000))]
[~,s] = sort(vpa(A));%vpa the symbolic before sorting.
A=A(s);%sorted symbolic
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Songbai Jin le 6 Mai 2022
But my original idea is to prevent a 'vpa' method.
Is it possible to sort sym variables directly?

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Number Theory dans Help Center et File Exchange

R2022a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by