nodes: 0, module; 1, function_definition; 2, function_name:get_sort_function; 3, parameters; 4, block; 5, identifier:order; 6, expression_statement; 7, expression_statement; 8, function_definition; 9, return_statement; 10, comment:"""
      Returns a callable similar to the built-in `cmp`, to be used on objects.
  
      Takes a list of dictionaries. In each, 'key' must be a string that is
      used to get an attribute of the objects to compare, and 'reverse' must
      be a boolean indicating whether the result should be reversed.
      """; 11, assignment; 12, function_name:sort_function; 13, parameters; 14, block; 15, identifier:sort_function; 16, identifier:stable; 17, call; 18, identifier:a; 19, identifier:b; 20, for_statement; 21, return_statement; 22, identifier:tuple; 23, generator_expression; 24, pattern_list; 25, identifier:stable; 26, block; 27, integer:0; 28, tuple; 29, for_in_clause; 30, identifier:name; 31, identifier:direction; 32, expression_statement; 33, if_statement; 34, subscript; 35, conditional_expression:-1 if d['reverse'] else 1; 36, identifier:d; 37, identifier:order; 38, assignment; 39, comparison_operator:v != 0; 40, block; 41, identifier:d; 42, string; 43, unary_operator; 44, subscript; 45, integer:1; 46, identifier:v; 47, call; 48, identifier:v; 49, integer:0; 50, return_statement; 51, string_content:key; 52, integer:1; 53, identifier:d; 54, string; 55, identifier:cmp; 56, argument_list; 57, binary_operator:v * direction; 58, string_content:reverse; 59, conditional_expression:getattr(a, name) if a else a; 60, conditional_expression:getattr(b, name) if b else b; 61, identifier:v; 62, identifier:direction; 63, call; 64, identifier:a; 65, identifier:a; 66, call; 67, identifier:b; 68, identifier:b; 69, identifier:getattr; 70, argument_list; 71, identifier:getattr; 72, argument_list; 73, identifier:a; 74, identifier:name; 75, identifier:b; 76, identifier:name
code: def get_sort_function(order):
      """
      Returns a callable similar to the built-in `cmp`, to be used on objects.
  
      Takes a list of dictionaries. In each, 'key' must be a string that is
      used to get an attribute of the objects to compare, and 'reverse' must
      be a boolean indicating whether the result should be reversed.
      """
      stable = tuple((d['key'], -1 if d['reverse'] else 1) for d in order)
      def sort_function(a, b):
          for name, direction in stable:
              v = cmp(getattr(a, name) if a else a, getattr(b, name) if b else b)
              if v != 0:
                  return v * direction
          return 0
      return sort_function