function [ascending,
descending] = myIndexing(inputArray)
temp =
inputArray;
%
Indices of the array in ascending order
ascending =
1:length(inputArray);
% Sort
input array in ascending order
for i =
1:(length(temp) - 1)
for j =
1:(length(temp) - 1)
if temp(j) > temp(j
+ 1)
% Swap
adjacent elements
x =
temp(j);
temp(j)
= temp(j + 1);
temp(j
+ 1) = x;
% Swap
adjacent elements of ascending
x =
ascending(j);
ascending(j) = ascending(j +
1);
ascending(j + 1) = x;
end
end
end
%
Descending will be reverse of ascending
descending =
ascending(length(ascending):-1:1);
end