%% Sort 3-D Array
% Create a 2-by-2-by-2 array and sort its elements in ascending order along the third dimension.

A(:,:,1) = [2 3; 1 6];
A(:,:,2) = [-1 9; 0 12];
A

%

B = sort(A,3)

%
% Use A(:), the column representation of A, to sort all of the elements of A.

B = sort(A(:))

% Copyright 2015 The MathWorks, Inc.