nodes: 0, module; 1, function_definition; 2, function_name:sort_timeseries; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, comment:# the time series is sorted by default; 9, if_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, return_statement; 15, identifier:ascending; 16, True; 17, comment:"""Sorts the data points within the TimeSeries according to their occurrence inline.
  
          :param boolean ascending: Determines if the TimeSeries will be ordered ascending or
              descending. If this is set to descending once, the ordered parameter defined in
              :py:meth:`TimeSeries.__init__` will be set to False FOREVER.
  
          :return:    Returns :py:obj:`self` for convenience.
          :rtype:     TimeSeries
          """; 18, boolean_operator; 19, block; 20, assignment; 21, not_operator; 22, block; 23, call; 24, assignment; 25, identifier:self; 26, identifier:ascending; 27, attribute; 28, return_statement; 29, identifier:sortorder; 30, integer:1; 31, identifier:ascending; 32, expression_statement; 33, expression_statement; 34, attribute; 35, argument_list; 36, attribute; 37, identifier:ascending; 38, identifier:self; 39, identifier:_sorted; 40, assignment; 41, assignment; 42, attribute; 43, identifier:sort; 44, keyword_argument; 45, identifier:self; 46, identifier:_sorted; 47, identifier:sortorder; 48, unary_operator; 49, attribute; 50, False; 51, identifier:self; 52, identifier:_timeseriesData; 53, identifier:key; 54, lambda; 55, integer:1; 56, identifier:self; 57, identifier:_predefinedSorted; 58, lambda_parameters; 59, binary_operator:sortorder * i[0]; 60, identifier:i; 61, identifier:sortorder; 62, subscript; 63, identifier:i; 64, integer:0
code: def sort_timeseries(self, ascending=True):
          """Sorts the data points within the TimeSeries according to their occurrence inline.
  
          :param boolean ascending: Determines if the TimeSeries will be ordered ascending or
              descending. If this is set to descending once, the ordered parameter defined in
              :py:meth:`TimeSeries.__init__` will be set to False FOREVER.
  
          :return:    Returns :py:obj:`self` for convenience.
          :rtype:     TimeSeries
          """
          # the time series is sorted by default
          if ascending and self._sorted:
              return
  
          sortorder = 1
          if not ascending:
              sortorder = -1
              self._predefinedSorted = False
  
          self._timeseriesData.sort(key=lambda i: sortorder * i[0])
  
          self._sorted = ascending
  
          return self