code: @Override
      public int compareTo(ServicePath servicePath) {
          // longer paths come first
          if (segments.length != servicePath.segments.length) {
              return servicePath.segments.length - segments.length;
          }
          else {
              for (int i = 0; i < segments.length; i++) {
                  boolean segmentIsParam = isParam(segments[i]);
                  boolean serviceSegmentIsParam = isParam(servicePath.segments[i]);
                  // non-params first
                  if (segmentIsParam && !serviceSegmentIsParam)
                      return 1;
                  else if (serviceSegmentIsParam && !segmentIsParam)
                      return -1;
              }
              return path.compareTo(servicePath.path);
          }
      }
docs: Sorting such that best match is found first.