shared-snippets/matlab/catalog/sortByTime.m

15 lines
419 B
Mathematica
Raw Normal View History

2024-08-29 13:01:31 +02:00
%
% -----------------
% Copyright © 2022 ACK Cyfronet AGH, Poland.
% -----------------
%
2024-08-28 17:22:21 +02:00
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