function r8row_sort_heap_index_a_test ( )

%*****************************************************************************80
%
%% r8row_sort_heap_index_a_test() tests r8row_sort_heap_index_a().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 February 2016
%
%  Author:
%
%    John Burkardt
%
  m = 15;
  n = 3;

  a = [ ...
  2.0,  6.0, 10.0; ...
  4.0,  8.0, 12.0; ...
  1.0,  5.0,  9.0; ...
  3.0,  7.0, 11.0; ...
  2.0,  6.0,  0.0; ...
  3.0,  4.0, 18.0; ...
  0.0,  0.0,  0.0; ...
  0.0,  6.0, 10.0; ...
  2.0,  6.0, 10.0; ...
  3.0,  7.0, 11.0; ...
  2.0,  0.0, 10.0; ...
  2.0,  6.0, 10.0; ...
  1.0,  5.0,  9.0; ...
  1.0,  5.0,  9.1; ...
  1.0,  5.1,  9.0 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8ROW_SORT_HEAP_INDEX_A_TEST\n' );
  fprintf ( 1, '  R8ROW_SORT_HEAP_INDEX_A computes an index vector which\n' );
  fprintf ( 1, '  ascending sorts an R8ROW.\n' );

  r8row_transpose_print ( m, n, a, '  The unsorted R8ROW:' );

  indx = r8row_sort_heap_index_a ( m, n, a );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The implicitly sorted R8ROW\n' );
  fprintf ( 1, '\n' );

  for i = 1 : m
    i2 = indx(i);
    fprintf ( 1, '  %4d:', i2 );
    for j = 1 : n
      fprintf ( 1, '  %f10.1', a(i2,j) );
    end
    fprintf ( 1, '\n' );
  end

  return
end
