sort 3 column matrix by two key words

2 Ansichten (letzte 30 Tage)
HONG CHENG
HONG CHENG am 5 Dez. 2017
Kommentiert: HONG CHENG am 5 Dez. 2017
how to do this in matlab? sort the matrix raws first by the first column, then by the second column?
input = [
1 2 11
1 2 11
1 2 12
1 2 11
1 2 11
1 2 12
1 3 17
1 3 15
1 4 18
1 4 18
1 3 15
1 3 16
2 3 17
2 3 15
1 3 16
1 3 17
1 3 15
1 3 15
1 3 15
1 3 16
1 2 12
1 2 11
1 2 11
1 2 11
1 4 18
1 4 18
1 4 18
2 4 17
2 4 17
1 4 17
1 4 17
1 4 17
]
output = [1 2 11
1 2 11
1 2 12
1 2 11
1 2 11
1 2 12
1 2 12
1 2 11
1 2 11
1 2 11
1 3 17
1 3 15
1 3 15
1 3 16
1 3 16
1 3 17
1 3 15
1 3 15
1 3 15
1 3 16
1 4 18
1 4 18
1 4 18
1 4 18
1 4 18
1 4 17
1 4 17
1 4 17
2 3 17
2 3 15
2 4 17
2 4 17
]

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 5 Dez. 2017
output sortrows(input, [1 2]);
  1 Kommentar
HONG CHENG
HONG CHENG am 5 Dez. 2017
thanks a lot, this function is what I need.
I also have another question, maybe you are interested in it too
that problem in the link is based on this problem.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!