function [A,B] = gg250_lab_06_try(n)
% function [A,B] = gg250_lab_try(n)
% Partially sorts the elements in a vector array
% of n-elements on a single pass through the array.
% Input parameters
% n = input array
% Output parameters
% A = Unsorted array
% B = Partially sorted array
% Example
% [A,B] = gg250_lab_06_try(5)

% Make copies of the input array
A = rand(n,1);
B = A;
% Find the number of elements in the array
n = length(A)
% Step through the elements one-by-one, switching
% consecutive elements such that the lower element 
% comes before the higher element
for j = 1:(n-1)
   if B(j) > B(j+1)
      C = B(j+1);
      B(j+1) = B(j);
      B(j) = C;
    end
end