how to sort cells by date?
Show older comments
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 Comments
Walter Roberson
on 24 Aug 2015
Is 11\5\2007 before or after 11/5/2007 ?
Amr Hashem
on 24 Aug 2015
Answers (1)
Walter Roberson
on 24 Aug 2015
[~, order] = datenum(A(:,1));
sortedA = A(order,:);
3 Comments
Amr Hashem
on 24 Aug 2015
Walter Roberson
on 24 Aug 2015
Edited: Walter Roberson
on 24 Aug 2015
[~, order] = sort(datenum(A(:,1)));
sortedA = A(order,:);
Amr Hashem
on 24 Aug 2015
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!