More deterministic makefile generation: Java top-level types (from types.hal)

are now ordered.

Bug: 31372383
Test: hidl_test, hidl_test_java
Change-Id: I8b542f979f48bbf089ff8178b0e4cf75ce86cdaa
diff --git a/main.cpp b/main.cpp
index 1357223..ae7f6a8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -229,7 +229,15 @@
 
             Scope *rootScope = typesAST->scope();
 
-            for (const auto &type : rootScope->getSubTypes()) {
+            std::vector<NamedType *> subTypes = rootScope->getSubTypes();
+            std::sort(
+                    subTypes.begin(),
+                    subTypes.end(),
+                    [](const NamedType *a, const NamedType *b) -> bool {
+                        return a->fqName() < b->fqName();
+                    });
+
+            for (const auto &type : subTypes) {
                 if (type->isTypeDef()) {
                     continue;
                 }