package mortar.bundler;

import java.util.Comparator;
import mortar.MortarScope;

class BundleServiceComparator implements Comparator<BundleService> {
  @Override public int compare(BundleService left, BundleService right) {
    String[] leftPath = left.scope.getPath().split(MortarScope.DIVIDER);
    String[] rightPath = right.scope.getPath().split(MortarScope.DIVIDER);

    if (leftPath.length != rightPath.length) {
      return Integer.compare(leftPath.length, rightPath.length);
    }

    int segments = leftPath.length;
    for (int i = 0; i < segments; i++) {
      int result = leftPath[i].compareTo(rightPath[i]);
      if (result != 0) return result;
    }

    return 0;
  }
}

@@ -431,24 +431,8 @@
 urn 
-Integer.compare(
 left
@@ -442,17 +442,18 @@
 h.length
-,
+ %3C
  rightPa
@@ -461,17 +461,25 @@
 h.length
-)
+ ? -1 : 1
 ;%0A    %7D%0A

use ternary operator instead of Integer#compare() that requires API level 19