code: def sorted_timeseries(self, ascending=True):
          
          sortorder = 1
          if not ascending:
              sortorder = -1
  
          data = sorted(self._timeseriesData, key=lambda i: sortorder * i[0])
  
          newTS = TimeSeries(self._normalized)
          for entry in data:
              newTS.add_entry(*entry)
  
          newTS._sorted = ascending
  
          return newTS
docs: Returns a sorted copy of the TimeSeries, preserving the original one.
  
          As an assumption this new TimeSeries is not ordered anymore if a new value is added.
  
          :param boolean ascending:    Determines if the TimeSeries will be ordered ascending
              or descending.
  
          :return:    Returns a new TimeSeries instance sorted in the requested order.
          :rtype:     TimeSeries