class_docstr: Implementation of knowledge graph interface in pglke.
  
  Args:
      triplets (dict):
          Triplet data of knowledge graphs with keys 'train', 'valid' and 'test'.
      num_ents (int, optional):
          Number of entities in a knowledge graph.
          If not provided, it will be inferred from triplets.
      num_rels (int, optional):
          Number of relations in a knowledge graph.
          If not provided, it will be inferred from triplets.
      ent_feat (np.ndarray, optional):
          Entity features, which have consistent order with entity ids.
      rel_feat (np.ndarray, optional):
          Relation features, which have consistent order with relation ids.
docstr: Get sorted training triplets with different strategies.
  
  Args:
      sorted_by (str):
          The axis as sort key. 'h': axis=0; 'r': axis=1; 't': axis=2.
  Return:
      np.ndarray: The sorted training triplets.
docstr_tok: ["Get","sorted","training","triplets","with","different","strategies",".","Args",":","sorted_by","(","str",")",":","The","axis","as","sort","key",".","'","h","'",":","axis=0",";","'","r","'",":","axis=1",";","'t","'",":","axis=2",".","Return",":","np.ndarray",":","The","sorted","training","triplets","."]
code: def sorted_triplets(self, sort_by="h"):
      """
      Get sorted training triplets with different strategies.
  
      Args:
          sorted_by (str):
              The axis as sort key. 'h': axis=0; 'r': axis=1; 't': axis=2.
      Return:
          np.ndarray: The sorted training triplets.
  
      """
      if sort_by == "h":
          sort_key = lambda x: (x[0], x[1])
      elif sort_by == "t":
          sort_key = lambda x: (x[2], x[1])
      else:
          sort_key = lambda x: x[1]
      return np.stack(sorted(self._train, key=sort_key))
  
imports: import os
  import json
  from collections import defaultdict
  import numpy
label_desc: Use image node_id 21 for calling the TriGraph obj's underlying member method code with example usage: obj.sorted_triplets(sort_by) and returns: np