function u2 = vector2d_angle_sort ( u )

%*****************************************************************************80
%
%% vector2d_angle_sort() sorts 2D vectors by angle, 0 to 360.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 November 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real u(n,2): n vectors in 2D.
%
%  Output:
%
%    real u2(n,2): n vectors in 2D, sorted by angle.
%
  rad = atan2 ( u(:,2), u(:,1) );

  [ rad, indx ] = sort ( rad );

  u2 = [ u(indx,1), u(indx,2) ];

  rad2 = atan2 ( u2(:,2), u2(:,1) );

  return
end
