title: How to sort a LatLng pointList in leaflet
body: <p>I have a pointList like the following</p>
  
  <pre><code>var pointList=[
  new L.LatLng(lat1,lon1),
  new L.LatLng(lat2,lon2),
  new L.LatLng(lat3,lon3),
  new L.LatLng(lat4,lon4),
  new L.LatLng(lat5,lon5),
  new L.LatLng(lat6,lon6),
  new L.LatLng(lat7,lon7)
  ];
  </code></pre>
  
  <p>I want to draw a polyLine using these points. I am using the following code to draw the polyLine</p>
  
  <pre><code>L.Polyline(pointList, {
      color: color,
      weight: 10,
      lineCap:"square",
      lineJoin:"bevel",
      opacity: 0.6,
      smoothFactor: 1
      });
  </code></pre>
  
  <p>But I am seeing multiple polyLines diverging from one point to another. That looks just weird. See the following image. 
  <img src="https://i.stack.imgur.com/wwyCf.jpg" alt="polylines"></p>
  
  <p>I guess if I could sort the points then I could get only one line instead of multiple lines. Can you give me any idea how to sort these points? Or is there any easy way to draw a polyline instead multiple diverging lines?</p>
  
  <p>I am attaching a <a href="http://jsfiddle.net/pyztr17y/1/" rel="nofollow noreferrer">jsfiddle</a> to give you an ide what i want to do. Remove the first entry from the pointlist and move it to the bottom. The line then looks progressing gradually. My goal is exactly like that.</p>