function x = r8vec_index_order ( n, x, indx )

%*****************************************************************************80
%
%% r8vec_index_order() sorts an integer vector using an index vector.
%
%  Discussion:
%
%    The index vector itself is not modified.  Therefore, the pair
%    (X,INDX) no longer represents an index sorted vector.  If this
%    relationship is to be preserved, then simply set INDX(1:N)=(1:N).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    31 October 2000
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the size of the current list.
%
%    real X(N), the list. 
%
%    integer INDX(N), the sort index of the list.
%
%  Output:
%
%    real X(N), the list has been sorted.
%
  y(1:n) = x(indx(1:n));
  x(1:n) = y(1:n);

  return
end
