diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go
index 9823842..8c200b0 100644
--- a/apex/apex_singleton.go
+++ b/apex/apex_singleton.go
@@ -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******************************";
