How do I sort an array in descending order without using the sort function?
Mostrar comentarios más antiguos
A = [2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19]
Respuesta aceptada
Más respuestas (2)
Walter Roberson
el 5 de Nov. de 2015
flipud(unique(A(:)))
Here are a few ways to sort an array of unique values without using sort:
sortrows(A(:),-1)
A(end:-1:1) = unique(A);
fliplr(union(A,A(1)))
fliplr(setdiff(A,NaN))
Categorías
Más información sobre Shifting and Sorting Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!