function sort (n, order, value)
% function ctos calculate x, y, and z from azimuth, elevation and distance
%  *              x       - x coordinate of image-model reflection
%  *              y       - y coordinate of image-model reflection
%  *              z       - z coordinate of image-model reflection
%  *              az      - azimuth incidence angles (degrees)
%  *              el      - elevation incidence angles (degrees)
%  *              r       - distance (m??)
% Translate from C code to matlab by Dennis Park 15.May.2014

    for i=1:n-1
        k = order[i];
        
        for j=i+1:n
            l = order[j];
            
            if value[k] > value[l] 
                order[i] = l;
                order[j] = k;
                k = l;
            end
        end
    end
end

