code: def ee_sort(text, events):
      new_events = []
      type_mapper = {}
      role_mapper = {}
      (
          positive_type,
          positive_role,
          positive_type_role,
      ) = get_positive_type_role(events, "EE")
      for ttype in positive_type:
          type_id = random.randint(0, 1000)
          type_mapper[ttype] = type_id
      for rrole in positive_role:
          role_id = random.randint(0, 1000)
          role_mapper[rrole] = role_id
  
      for event in events:
          type_id = type_mapper[event["event_type"]]
          event_offset = match_sublist(
              list(text), list(event["event_trigger"])
          )
          if len(event_offset) == 0:
              event_offset = [
                  [-100, -100],
              ]
          event_offset = event_offset[0]
          new_args = []
          for arg in event["arguments"]:
              role_id = role_mapper[arg["role"]]
              arg_offset = match_sublist(
                  list(text), list(arg["argument"])
              )
              if len(arg_offset) == 0:
                  arg_offset = [
                      [-100, -100],
                  ]
              arg_offset = arg_offset[0]
              new_args.append([arg, [arg_offset[0], role_id]])
          new_args = sorted(new_args, key=lambda x: (x[1][1], x[1][0]))
          new_args = [it[0] for it in new_args]
          event["arguments"] = new_args
          new_events.append([event, [event_offset[0], type_id]])
      new_events = sorted(new_events, key=lambda x: (x[1][1], x[1][0]))
      new_events = [it[0] for it in new_events]
      new_type_role_dict = {}
      for key, value in positive_type_role.items():
          sorted_value = sorted(value, key=lambda x: role_mapper[x])
          new_type_role_dict[key] = sorted_value
      new_type_role_dict = dict(
          sorted(
              new_type_role_dict.items(),
              key=lambda x: type_mapper[x[0]],
          )
      )
      return new_events, new_type_role_dict
  
file_path: DeepKE/example/llm/InstructKGC/kg2instruction/convert/random_sort.py
imports: import sys
  import random
  from convert.sampler import get_positive_type_role
label_desc: Use image node_id 3 for calling a global function with example usage: ee_sort(text, events) and returns: new_events,  new_type_role_dict