code: def _sort_vertex(vertices):
      # TODO Add typehints & docstring & test
      assert vertices.ndim == 2
      assert vertices.shape[-1] == 2
      N = vertices.shape[0]
      if N == 0:
          return vertices
  
      center = np.mean(vertices, axis=0)
      directions = vertices - center
      angles = np.arctan2(directions[:, 1], directions[:, 0])
      sort_idx = np.argsort(angles)
      vertices = vertices[sort_idx]
  
      left_top = np.min(vertices, axis=0)
      dists = np.linalg.norm(left_top - vertices, axis=-1, ord=2)
      lefttop_idx = np.argmin(dists)
      indexes = (np.arange(N, dtype=np.int_) + lefttop_idx) % N
      return vertices[indexes]
  
imports: import math
  import operator
  from functools import reduce
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import pyclipper
  import shapely
  from mmengine.utils import is_list_of
  from shapely.geometry import MultiPolygon, Polygon
  from mmocr.utils import bbox2poly, valid_boundary
  from mmocr.utils.check_argument import is_2dlist
  from mmocr.utils.typing_utils import ArrayLike
label_desc: Use image node_id 17 for calling a global function with example usage: _sort_vertex(vertices) and returns: vertices, vertices