I have a Python script that generates layout and I need to arrange the polygon vertices clockwise Like Image_1

my script to extract polygon vertices not clockwise.
Â
def extract_polygon_vertices(feature_layer😞
  results = []
  with arcpy.da.SearchCursor(feature_layer, ["SHAPE@"]) as cursor:
    for row in cursor:
      geom = row[0]
      if geom:
        vertices = [(pnt.X, pnt.Y) for part in geom.getPart() for pnt in part if pnt]
        vertices = order_vertices(vertices)Â
        for i in range(len(vertices)):
          if i > 0 and vertices[i] == vertices[i - 1]:
            continue
          pnt1 = vertices[i]
          pnt2 = vertices[i - 1] if i > 0 else vertices[-1]
          length = calculate_distance(pnt2, pnt1)
          results.append((pnt1, pnt2, length))
      else:
        add_error_message("No geometry available.")
  del cursor
  return results
Â
Â
def order_vertices(vertices😞  Â
  """
  Â
  Order the vertices in a clockwise direction starting from the highest Y coordinate.
  """
  if not vertices:
    return []
  ordered_vertices = []
  # Get the highest Y coordinate
  highest_y = max(vertices, key=lambda vertex: vertex[1])
  highest_y_index = vertices.index(highest_y)
  # Check if multiple points have the same highest Y and choose the most left one (smallest X)
  top_points = [v for v in vertices if v[1] == highest_y[1]]
  start_point = min(top_points, key=lambda vertex: vertex[0])
  start_point_index = vertices.index(start_point)
  # Order the points starting from start_point to the end, then from the beginning to start_point
  ordered_vertices = vertices[start_point_index:] + vertices[:start_point_index]
  return ordered_vertices
Â
Â
Image_2 : the incorrect ouptut

Â