Borrar filtros
Borrar filtros

How to sort a table with conditions of pair of values

3 visualizaciones (últimos 30 días)
Vasiliki Charisi
Vasiliki Charisi el 1 de Nov. de 2015
Editada: Andrei Bobrov el 1 de Nov. de 2015
I have a table
1 2 3 4
1 2 8 10
4 5 7 9
2 3 6 4
1 2 4 7
2 3 5 3
and I want it to be sorted using as a condition the pair of values existing in the first and the second column and I want to first find all rows according to all possible pairs and then the rest of the rows. The end result of the table should be
1 2 3 4
1 2 4 7
1 2 8 10
2 3 5 3
2 3 6 4
4 5 7 9
How do I sort a table like this? I have no idea what to do and any help would be appreciated.

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 1 de Nov. de 2015
Editada: Andrei Bobrov el 1 de Nov. de 2015
a = [1 2 3 4
1 2 8 10
4 5 7 9
2 3 6 4
1 2 4 7
2 3 5 3];
out = sortrows(a);

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by