code: def AddShapePointObjectUnsorted(self, shapepoint, problems):
      if (len(self.sequence) == 0 or
          shapepoint.shape_pt_sequence >= self.sequence[-1]):
        index = len(self.sequence)
      elif shapepoint.shape_pt_sequence <= self.sequence[0]:
        index = 0
      else:
        index = bisect.bisect(self.sequence, shapepoint.shape_pt_sequence)
      if shapepoint.shape_pt_sequence in self.sequence:
        problems.InvalidValue('shape_pt_sequence', shapepoint.shape_pt_sequence,
                              'The sequence number %d occurs more than once in '
                              'shape %s.' %
                              (shapepoint.shape_pt_sequence, self.shape_id))
      if shapepoint.shape_dist_traveled is not None and len(self.sequence) > 0:
        if (index != len(self.sequence) and
            shapepoint.shape_dist_traveled > self.distance[index]):
          problems.InvalidValue('shape_dist_traveled',
                                shapepoint.shape_dist_traveled,
                                'Each subsequent point in a shape should have '
                                'a distance value that shouldn\'t be larger '
                                'than the next ones. In this case, the next '
                                'distance was %f.' % self.distance[index])
        if (index > 0 and
            shapepoint.shape_dist_traveled < self.distance[index - 1]):
          problems.InvalidValue('shape_dist_traveled',
                                shapepoint.shape_dist_traveled,
                                'Each subsequent point in a shape should have '
                                'a distance value that\'s at least as large as '
                                'the previous ones. In this case, the previous '
                                'distance was %f.' % self.distance[index - 1])
      if shapepoint.shape_dist_traveled > self.max_distance:
        self.max_distance = shapepoint.shape_dist_traveled
      self.sequence.insert(index, shapepoint.shape_pt_sequence)
      self.distance.insert(index, shapepoint.shape_dist_traveled)
      self.points.insert(index, (shapepoint.shape_pt_lat,
                                 shapepoint.shape_pt_lon,
                                 shapepoint.shape_dist_traveled))