function [x,TotalC,TotalS] = BubbleSort1(x)
% Sort x in ascending order using bubble sort.
% x is a column n-vector.
% TotalC is the total number of required comparisons.
% TotalS is the total number of required swaps.

n = length(x); TotalC = 0; TotalS = 0;
for k = 1:n-1
    [x(k:n),C,S] = Bubble(x(k:n));
    TotalC = TotalC + C;
    TotalS = TotalS + S;
end
