nodes: 0, module; 1, function_definition; 2, function_name:sort_schemas; 3, parameters; 4, block; 5, identifier:schemas; 6, expression_statement; 7, function_definition; 8, return_statement; 9, comment:"""Sort a list of SQL schemas in order"""; 10, function_name:keyfun; 11, parameters; 12, block; 13, call; 14, identifier:v; 15, expression_statement; 16, comment:# x3: 'DEV' should come before ''; 17, return_statement; 18, identifier:sorted; 19, argument_list; 20, assignment; 21, tuple; 22, identifier:schemas; 23, keyword_argument; 24, identifier:x; 25, call; 26, call; 27, subscript; 28, conditional_expression:int(x[2]) if x[2] else None; 29, conditional_expression:x[3] if x[3] else 'zzz'; 30, call; 31, identifier:key; 32, identifier:keyfun; 33, attribute; 34, argument_list; 35, identifier:int; 36, argument_list; 37, identifier:x; 38, integer:1; 39, call; 40, subscript; 41, None; 42, subscript; 43, subscript; 44, string; 45, identifier:int; 46, argument_list; 47, call; 48, identifier:groups; 49, subscript; 50, identifier:int; 51, argument_list; 52, identifier:x; 53, integer:2; 54, identifier:x; 55, integer:3; 56, identifier:x; 57, integer:3; 58, string_content:zzz; 59, subscript; 60, attribute; 61, argument_list; 62, identifier:x; 63, integer:0; 64, subscript; 65, identifier:x; 66, integer:4; 67, identifier:SQL_SCHEMA_REGEXP; 68, identifier:match; 69, identifier:v; 70, identifier:x; 71, integer:2
code: def sort_schemas(schemas):
      """Sort a list of SQL schemas in order"""
      def keyfun(v):
          x = SQL_SCHEMA_REGEXP.match(v).groups()
          # x3: 'DEV' should come before ''
          return (int(x[0]), x[1], int(x[2]) if x[2] else None,
                  x[3] if x[3] else 'zzz', int(x[4]))
  
      return sorted(schemas, key=keyfun)