nodes: 0, module; 1, function_definition; 2, function_name:glyph_order; 3, parameters; 4, block; 5, identifier:keys; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, function_definition; 10, return_statement; 11, identifier:draw_order; 12, list; 13, comment:"""
      Orders a set of glyph handles using regular sort and an explicit
      sort order. The explicit draw order must take the form of a list
      of glyph names while the keys should be glyph names with a custom
      suffix. The draw order may only match subset of the keys and any
      matched items will take precedence over other entries.
      """; 14, assignment; 15, function_name:order_fn; 16, parameters; 17, block; 18, call; 19, identifier:keys; 20, call; 21, identifier:glyph; 22, expression_statement; 23, return_statement; 24, identifier:sorted; 25, argument_list; 26, identifier:sorted; 27, argument_list; 28, assignment; 29, parenthesized_expression; 30, identifier:keys; 31, keyword_argument; 32, identifier:keys; 33, identifier:matches; 34, list_comprehension; 35, conditional_expression:(draw_order.index(matches[0]), glyph) if matches else
                  (1e9+keys.index(glyph), glyph); 36, identifier:key; 37, identifier:order_fn; 38, identifier:item; 39, for_in_clause; 40, if_clause; 41, tuple; 42, identifier:matches; 43, tuple; 44, identifier:item; 45, identifier:draw_order; 46, call; 47, call; 48, identifier:glyph; 49, binary_operator:1e9+keys.index(glyph); 50, identifier:glyph; 51, attribute; 52, argument_list; 53, attribute; 54, argument_list; 55, float:1e9; 56, call; 57, identifier:glyph; 58, identifier:startswith; 59, identifier:item; 60, identifier:draw_order; 61, identifier:index; 62, subscript; 63, attribute; 64, argument_list; 65, identifier:matches; 66, integer:0; 67, identifier:keys; 68, identifier:index; 69, identifier:glyph
code: def glyph_order(keys, draw_order=[]):
      """
      Orders a set of glyph handles using regular sort and an explicit
      sort order. The explicit draw order must take the form of a list
      of glyph names while the keys should be glyph names with a custom
      suffix. The draw order may only match subset of the keys and any
      matched items will take precedence over other entries.
      """
      keys = sorted(keys)
      def order_fn(glyph):
          matches = [item for item in draw_order if glyph.startswith(item)]
          return ((draw_order.index(matches[0]), glyph) if matches else
                  (1e9+keys.index(glyph), glyph))
      return sorted(keys, key=order_fn)