Borrar filtros
Borrar filtros

how to sort cells by date?

5 visualizaciones (últimos 30 días)
Amr Hashem
Amr Hashem el 24 de Ag. de 2015
Comentada: Amr Hashem el 24 de Ag. de 2015
i have a column of dates DD\MM\YYYY, i want to sort them by date .
i try:
sort(A);
but it sorts them by days
how i can do this?
  2 comentarios
Walter Roberson
Walter Roberson el 24 de Ag. de 2015
Is 11\5\2007 before or after 11/5/2007 ?
Amr Hashem
Amr Hashem el 24 de Ag. de 2015
Are you joking? what do you mean?

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 24 de Ag. de 2015
[~, order] = datenum(A(:,1));
sortedA = A(order,:);
  3 comentarios
Walter Roberson
Walter Roberson el 24 de Ag. de 2015
Editada: Walter Roberson el 24 de Ag. de 2015
[~, order] = sort(datenum(A(:,1)));
sortedA = A(order,:);
Amr Hashem
Amr Hashem el 24 de Ag. de 2015
Thanks... it works, but it didn't sort all of them.
as I discovered that some of dates written in the form "dd/mm/yyyy" and others "mm/dd/yyyy".
so it seems that I have to convert them first to one form.

Iniciar sesión para comentar.

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