function [ n, x, indx ] = r8vec_index_sort_unique ( n, x )

%*****************************************************************************80
%
%% r8vec_index_sort_unique() creates a sort index for an R8VEC.
%
%  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.  
%
%  Output:
%
%    integer N, the number of unique elements in X.
%
%    real X(N), the list contains only unique elements.
%
%    integer INDX(N), the sort index of the list.
%
  n2 = 0;
  y = [];
  indx = [];

  for i = 1 : n
    [ n2, y, indx ] = r8vec_index_insert_unique ( n2, y, indx, x(i) );
  end

  n = n2;
  x = y(1:n);

  return
end

