shared-snippets/matlab/catalog/sortByTime.m

15 lines
419 B
Matlab

%
% -----------------
% Copyright © 2022 ACK Cyfronet AGH, Poland.
% -----------------
%
function [sortedCatalog] = sortByTime(catalog)
timeColIndex = find(strcmp('Time', {catalog.field}));
if ~isempty(timeColIndex)
[~, sortedIndexes] = sortrows(catalog(timeColIndex).val);
for i=1:length(catalog)
catalog(i).val = catalog(i).val(sortedIndexes);
end
end
sortedCatalog = catalog;
end