nodes: 0, module; 1, function_definition; 2, function_name:sort2groups; 3, parameters; 4, block; 5, identifier:array; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, identifier:gpat; 13, list; 14, comment:""" Sort an array of strings to groups by patterns """; 15, assignment; 16, assignment; 17, identifier:item; 18, identifier:array; 19, block; 20, expression_list; 21, string; 22, string; 23, identifier:groups; 24, list_comprehension; 25, identifier:unmatched; 26, list; 27, expression_statement; 28, for_statement; 29, if_statement; 30, list_comprehension; 31, call; 32, string_content:_R1; 33, string_content:_R2; 34, call; 35, for_in_clause; 36, assignment; 37, identifier:m; 38, identifier:groups; 39, block; 40, not_operator; 41, block; 42, call; 43, for_in_clause; 44, identifier:sorted; 45, argument_list; 46, identifier:REGroup; 47, argument_list; 48, identifier:gp; 49, identifier:gpat; 50, identifier:matched; 51, False; 52, if_statement; 53, identifier:matched; 54, expression_statement; 55, identifier:sorted; 56, argument_list; 57, identifier:m; 58, identifier:groups; 59, identifier:unmatched; 60, identifier:gp; 61, call; 62, block; 63, call; 64, attribute; 65, attribute; 66, argument_list; 67, expression_statement; 68, break_statement; 69, attribute; 70, argument_list; 71, identifier:m; 72, identifier:list; 73, identifier:m; 74, identifier:match; 75, identifier:item; 76, assignment; 77, identifier:unmatched; 78, identifier:append; 79, identifier:item; 80, identifier:matched; 81, True
code: def sort2groups(array, gpat=['_R1','_R2']):
     """ Sort an array of strings to groups by patterns """
     groups = [REGroup(gp) for gp in gpat]
     unmatched = []
     for item in array:
        matched = False
        for m in groups:
           if m.match(item):
              matched = True
              break
        if not matched: unmatched.append(item)
     return [sorted(m.list) for m in groups], sorted(unmatched)