code: def sort(key, new=new):
      """Create a rule to sort by a key function.
  
      Examples
      ========
  
      >>> from sympy.strategies import sort
      >>> from sympy import Basic, S
      >>> sort_rl = sort(str)
      >>> sort_rl(Basic(S(3), S(1), S(2)))
      Basic(1, 2, 3)
      """
  
      def sort_rl(expr):
          return new(expr.__class__, *sorted(expr.args, key=key))
  
      return sort_rl
  
file_path: sympy/sympy/strategies/rl.py
imports: from sympy.utilities.iterables import sift
  from .util import new
label_desc: Use image node_id 3 for calling a global function with example usage: sort(key, new) and returns: sort_rl, new