code: function() {
          var numSeg = this.components.length - 1;
          var segments = new Array(numSeg), point1, point2;
          for(var i=0; i<numSeg; ++i) {
              point1 = this.components[i];
              point2 = this.components[i + 1];
              if(point1.x < point2.x) {
                  segments[i] = {
                      x1: point1.x,
                      y1: point1.y,
                      x2: point2.x,
                      y2: point2.y
                  };
              } else {
                  segments[i] = {
                      x1: point2.x,
                      y1: point2.y,
                      x2: point1.x,
                      y2: point1.y
                  };
              }
          }
          // more efficient to define this somewhere static
          function byX1(seg1, seg2) {
              return seg1.x1 - seg2.x1;
          }
          return segments.sort(byX1);
      }
docs: Method: getSortedSegments
  
  Returns:
  {Array} An array of segment objects.  Segment objects have properties
  x1, y1, x2, and y2.  The start point is represented by x1 and y1.
  The end point is represented by x2 and y2.  Start and end are
  ordered so that x1 < x2.