code: def sort_timeseries(self, ascending=True):
          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