docs: def sort(polylines):
      """
      sort points within polyline
      p0-p1-p2...
      """
      for n, c in enumerate(polylines):
          l = len(c)
          if l > 2:
              # DEFINE FIRST AND LAST INDEX A THOSE TWO POINTS THAT
              # HAVE THE BIGGEST DIFFERENCE FROM A MIDDLE:
              mid = c.mean(axis=0)
  
              distV = (c - mid)
              dists = norm(distV, axis=-1)
  
              firstI = np.argmax(dists)
              sign = np.sign(distV[firstI])
  
              dd = np.logical_or(np.sign(distV[:, 0]) != sign[0],
                                 np.sign(distV[:, 1]) != sign[1])
  
              dists[~dd] = 0
              lastI = np.argmax(dists)
  
              ind = _sort(c, firstI, lastI)
              c = c[ind]
              polylines[n] = c