code: def sort_line_bbox(g, bg):
      """
      Sorted the bbox in the same line(group)
      compare coord 'x' value, where 'y' value is closed in the same group.
      :param g: index in the same group
      :param bg: bbox in the same group
      :return:
      """
  
      xs = [bg_item[0] for bg_item in bg]
      xs_sorted = sorted(xs)
  
      g_sorted = [None] * len(xs_sorted)
      bg_sorted = [None] * len(xs_sorted)
      for g_item, bg_item in zip(g, bg):
          idx = xs_sorted.index(bg_item[0])
          bg_sorted[idx] = bg_item
          g_sorted[idx] = g_item
  
      return g_sorted, bg_sorted
  
imports: import os
  import re
  import cv2
  import glob
  import copy
  import math
  import pickle
  import numpy
  from shapely.geometry import Polygon, MultiPoint
label_desc: Use image node_id 11 for calling a global function with example usage: sort_line_bbox(g, bg) and returns: g_sorted,  bg_sorted