diff --git a/apex_singleton.go b/apex_singleton.go.patched
index 6faed7011..d61bb5c53 100644
--- a/apex_singleton.go
+++ b/apex_singleton.go.patched
@@ -50,8 +50,10 @@ var (
 	// Diff two given lists while ignoring comments in the allowed deps file.
 	diffAllowedApexDepsInfoRule = pctx.AndroidStaticRule("diffAllowedApexDepsInfoRule", blueprint.RuleParams{
 		Description: "Diff ${allowed_deps} and ${new_allowed_deps}",
+		// CBBA:PATCH
+		// Sort the modules the same way before creating the new list.
 		Command: `
-			if grep -v '^#' ${allowed_deps} | diff -B - ${new_allowed_deps}; then
+			if grep -v '^#' ${allowed_deps} | sort -u -f | diff -B - ${new_allowed_deps}; then
 			   touch ${out};
 			else
 				echo -e "\n******************************";
