code: function byLeastSpecificLayer(a, b) {
    var regexpA = a.path && typeof a.path === 'object';
    var regexpB = b.path && typeof b.path === 'object';
    var pathA = normalizeLayerPath(a.path);
    var pathB = normalizeLayerPath(b.path);
    var wildA = pathA.endsWith('(.*)');
    var wildB = pathB.endsWith('(.*)');
    if (wildA && wildB) return pathA.length - pathB.length;
    pathA = wildA ? pathA.slice(0, -4) : pathA;
    pathB = wildB ? pathB.slice(0, -4) : pathB;
    if (pathA !== pathB) {
      if (pathA.startsWith(pathB)) return 1;
      if (pathB.startsWith(pathA)) return -1;
    }
    if (wildA) return -1;
    if (wildB) return 1;
    if (regexpA && !regexpB) {
      return -1;
    }
    if (!regexpA && regexpB) {
      return 1;
    }
    return 0;
  }
docs: Copied from
  https://github.com/ZijianHe/koa-router/pull/475, which would fix the mentioned issues with ctx._matchedRoute (if
  it got merged).
  
  Sort function for array of Layers. Will sort the layers with least specific first
  and most specific last.
  
  @param {Layer} a
  @param {Layer} b