Effacer les filtres
Effacer les filtres

Sort rows or cells (descending first column) where second column has repeated value

1 vue (au cours des 30 derniers jours)
I have a set of points (x, y) in a matrix and want to re-arrange them according to a criteria.
Original : x ----- y (dots showing rows to arrange)
162, 59
161, 60
. 159, 61
. 160, 61
158, 62
157, 63
. 155, 64
. 156, 64
. 157, 64
. 153, 65
. 154, 65
152, 66
I need to sort them by row (descending within column 1, x) where my column 2 (y) has a repeated value.
Arranged: x ----- y
162, 59
161, 60
. 160, 61
. 159, 61
158, 62
157, 63
. 157, 64
. 156, 64
. 155, 64
. 154, 65
. 153, 65
152, 66
Since column 2 always has the same value within the criteria, I should sort only the column 1 (always within the criteria, of course).
Preferably without using loops. I am looking for the correct MATLAB way of doing it.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 5 Mar 2013
Modifié(e) : Azzi Abdelmalek le 5 Mar 2013
Use sortrows
B=flipud(sortrows(A,1))
  6 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 5 Mar 2013
I did not understand your question
Mauricio Escobar
Mauricio Escobar le 5 Mar 2013
Modifié(e) : Mauricio Escobar le 5 Mar 2013
Sorry! I am obviously not thinking straight. Since it will be the same thing as in my original.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by