code: def coalesce(self):
          self.sort(key=lambda ts: ts.t0.value)
          i = j = 0
          N = len(self)
          while j < N:
              this = self[j]
              j += 1
              if j < N and this.is_contiguous(self[j]) == 1:
                  while j < N and this.is_contiguous(self[j]):
                      try:
                          this = self[i] = this.append(self[j])
                      except ValueError as exc:
                          if 'cannot resize this array' in str(exc):
                              this = this.copy()
                              this = self[i] = this.append(self[j])
                          else:
                              raise
                      j += 1
              else:
                  self[i] = this
              i += 1
          del self[i:]
          return self