% Sort an array of objects
% Example: Sort an array of Intervals from narrowest to widest

% Create an array of n Intervals
n= 5;
A= intervalArray(n);

% Display the Intervals in array A
disp(' Original order:')
for k= 1:n
fprintf('Width=%.4f ', A(k).getWidth())
disp(A(k))
end

% Sort the Intervals in array A
[sortedA, totalC, totalS]= InsertionSortIntervals(A);

% Display the Intervals in array sortedA
disp(' Sorted order:')
for k= 1:n
fprintf('Width=%.4f ', sortedA(k).getWidth())
disp(sortedA(k))
end