ensure bundle order is respected in startup.properties
diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
index a4d4205..7dd741b 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
@@ -109,6 +109,7 @@
 import org.slf4j.LoggerFactory;
 
 import static java.util.Collections.singletonList;
+import static java.util.Comparator.comparing;
 import static java.util.jar.JarFile.MANIFEST_NAME;
 import static org.apache.karaf.profile.assembly.Builder.Stage.Startup;
 
@@ -1962,7 +1963,10 @@
         Map<Integer, Set<String>> invertedStartupBundles = MapUtils.invert(bundles);
         for (Map.Entry<Integer, Set<String>> entry : new TreeMap<>(invertedStartupBundles).entrySet()) {
             String startLevel = Integer.toString(entry.getKey());
-            for (String location : new TreeSet<>(entry.getValue())) {
+            // ensure input order is respected whatever hashmap/set was in the middle of the processing
+            final List<String> value = new ArrayList<>(entry.getValue());
+            value.sort(comparing(bnd -> startupEffective.getBundles().indexOf(bnd)));
+            for (String location : value) {
                 if (useReferenceUrls) {
                     if (location.startsWith("mvn:")) {
                         location = "file:" + Parser.pathFromMaven(location);