nodes: 0, module; 1, function_definition; 2, function_name:_PreparedData; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, if_statement; 11, for_statement; 12, return_statement; 13, identifier:order_by; 14, tuple; 15, comment:"""Prepares the data for enumeration - sorting it by order_by.
  
      Args:
        order_by: Optional. Specifies the name of the column(s) to sort by, and
                  (optionally) which direction to sort in. Default sort direction
                  is asc. Following formats are accepted:
                  "string_col_name"  -- For a single key in default (asc) order.
                  ("string_col_name", "asc|desc") -- For a single key.
                  [("col_1","asc|desc"), ("col_2","asc|desc")] -- For more than
                      one column, an array of tuples of (col_name, "asc|desc").
  
      Returns:
        The data sorted by the keys given.
  
      Raises:
        DataTableException: Sort direction not in 'asc' or 'desc'
      """; 16, not_operator; 17, block; 18, assignment; 19, boolean_operator; 20, block; 21, identifier:key; 22, call; 23, block; 24, identifier:sorted_data; 25, identifier:order_by; 26, return_statement; 27, identifier:sorted_data; 28, subscript; 29, call; 30, parenthesized_expression; 31, expression_statement; 32, identifier:reversed; 33, argument_list; 34, if_statement; 35, attribute; 36, attribute; 37, slice; 38, identifier:isinstance; 39, argument_list; 40, boolean_operator; 41, assignment; 42, identifier:order_by; 43, call; 44, block; 45, elif_clause; 46, else_clause; 47, identifier:self; 48, identifier:__data; 49, identifier:self; 50, identifier:__data; 51, identifier:order_by; 52, attribute; 53, boolean_operator; 54, comparison_operator:order_by[1].lower() in ["asc", "desc"]; 55, identifier:order_by; 56, tuple; 57, identifier:isinstance; 58, argument_list; 59, expression_statement; 60, parenthesized_expression; 61, block; 62, block; 63, identifier:six; 64, identifier:string_types; 65, call; 66, comparison_operator:len(order_by) == 2; 67, call; 68, list; 69, identifier:order_by; 70, identifier:key; 71, attribute; 72, call; 73, boolean_operator; 74, expression_statement; 75, expression_statement; 76, raise_statement; 77, identifier:isinstance; 78, argument_list; 79, call; 80, integer:2; 81, attribute; 82, argument_list; 83, string:"asc"; 84, string:"desc"; 85, identifier:six; 86, identifier:string_types; 87, attribute; 88, argument_list; 89, boolean_operator; 90, comparison_operator:key[1].lower() in ("asc", "desc"); 91, assignment; 92, call; 93, call; 94, identifier:order_by; 95, identifier:tuple; 96, identifier:len; 97, argument_list; 98, subscript; 99, identifier:lower; 100, identifier:sorted_data; 101, identifier:sort; 102, keyword_argument; 103, call; 104, comparison_operator:len(key) == 2; 105, call; 106, tuple; 107, identifier:key_func; 108, lambda; 109, attribute; 110, argument_list; 111, identifier:DataTableException; 112, argument_list; 113, identifier:order_by; 114, identifier:order_by; 115, integer:1; 116, identifier:key; 117, lambda; 118, identifier:isinstance; 119, argument_list; 120, call; 121, integer:2; 122, attribute; 123, argument_list; 124, string:"asc"; 125, string:"desc"; 126, lambda_parameters; 127, call; 128, identifier:sorted_data; 129, identifier:sort; 130, keyword_argument; 131, keyword_argument; 132, concatenated_string; 133, lambda_parameters; 134, call; 135, identifier:key; 136, tuple; 137, identifier:len; 138, argument_list; 139, subscript; 140, identifier:lower; 141, identifier:x; 142, attribute; 143, argument_list; 144, identifier:key; 145, identifier:key_func; 146, identifier:reverse; 147, comparison_operator:key[1].lower() != "asc"; 148, string:"Expected tuple with second value: "; 149, string:"'asc' or 'desc'"; 150, identifier:x; 151, attribute; 152, argument_list; 153, identifier:list; 154, identifier:tuple; 155, identifier:key; 156, identifier:key; 157, integer:1; 158, subscript; 159, identifier:get; 160, subscript; 161, call; 162, string:"asc"; 163, subscript; 164, identifier:get; 165, identifier:key; 166, identifier:x; 167, integer:0; 168, identifier:key; 169, integer:0; 170, attribute; 171, argument_list; 172, identifier:x; 173, integer:0; 174, subscript; 175, identifier:lower; 176, identifier:key; 177, integer:1
code: def _PreparedData(self, order_by=()):
      """Prepares the data for enumeration - sorting it by order_by.
  
      Args:
        order_by: Optional. Specifies the name of the column(s) to sort by, and
                  (optionally) which direction to sort in. Default sort direction
                  is asc. Following formats are accepted:
                  "string_col_name"  -- For a single key in default (asc) order.
                  ("string_col_name", "asc|desc") -- For a single key.
                  [("col_1","asc|desc"), ("col_2","asc|desc")] -- For more than
                      one column, an array of tuples of (col_name, "asc|desc").
  
      Returns:
        The data sorted by the keys given.
  
      Raises:
        DataTableException: Sort direction not in 'asc' or 'desc'
      """
      if not order_by:
        return self.__data
  
      sorted_data = self.__data[:]
      if isinstance(order_by, six.string_types) or (
          isinstance(order_by, tuple) and len(order_by) == 2 and
          order_by[1].lower() in ["asc", "desc"]):
        order_by = (order_by,)
      for key in reversed(order_by):
        if isinstance(key, six.string_types):
          sorted_data.sort(key=lambda x: x[0].get(key))
        elif (isinstance(key, (list, tuple)) and len(key) == 2 and
              key[1].lower() in ("asc", "desc")):
          key_func = lambda x: x[0].get(key[0])
          sorted_data.sort(key=key_func, reverse=key[1].lower() != "asc")
        else:
          raise DataTableException("Expected tuple with second value: "
                                   "'asc' or 'desc'")
  
      return sorted_data