code: def sort(packed, ref, reverse=True):
      """
      Sort a series of packed list, according to a ref list.
      Also return the original index before the sort.
      """
      assert (
          isinstance(packed, tuple) or isinstance(packed, list)
      ) and isinstance(ref, list)
      packed = [ref] + [range(len(ref))] + list(packed)
      sorted_packed = [
          list(t) for t in zip(*sorted(zip(*packed), reverse=reverse))
      ]
      return tuple(sorted_packed[1:])
  
file_path: stanza/stanza/models/common/seq2seq_utils.py
imports: from collections import Counter
  import random
  import json
  import torch
  import stanza.models.common.seq2seq_constant
label_desc: Use image node_id 11 for calling a global function with example usage: sort(packed, ref, reverse) and returns: tuple