RebuildNoteDb: Sort project names for stable output

Change-Id: I6da41c73fc26ead2f6591bdb032c34afbf549d36
diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/RebuildNoteDb.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/RebuildNoteDb.java
index c2f99f1..53ee8cc 100644
--- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/RebuildNoteDb.java
+++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/RebuildNoteDb.java
@@ -20,6 +20,7 @@
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Multimap;
+import com.google.common.collect.Ordering;
 import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -136,7 +137,9 @@
     Stopwatch sw = Stopwatch.createStarted();
     try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) {
       deleteRefs(RefNames.REFS_DRAFT_COMMENTS, allUsersRepo);
-      for (Project.NameKey project : changesByProject.keySet()) {
+      List<Project.NameKey> projectNames = Ordering.usingToString()
+          .sortedCopy(changesByProject.keySet());
+      for (Project.NameKey project : projectNames) {
         try {
           List<ListenableFuture<?>> futures = Lists.newArrayList();