MATLAB: Sorting cell array by date

cell arraydatesort

Hi everybody,
i have cell array, which includes a specific column with dates (dd.mm.yyyy_HH:mm:ss). I want to sort the whole array by this dates. Can anybody help me out?
Matlab R2016a

Best Answer

Your data are already sorted:
D = load('sort-by-2nd-column.mat');
Data = D.GivenData;
[dn,idx] = sort(datenum(Data(2:end,2), 'dd.mm.yyyy_hh:MM:ss'), 1, 'ascend');
There is nothing to do.
[EDITED, copied from comment]
% First Row Are Column Labels
Data = D.GivenData(2:end,:);
% First Output Of ‘sort’ Not Necessary, So Not Returned
[~,idx] = sort(datenum(Data(:,2), 'dd.mm.yyyy_hh:MM:ss'), 1, 'ascend');
Data_Sorted = Data(idx,:);
Related Question