Merge "Fix androidmk module ordering" am: 5f234d565c
am: 127611d062

Change-Id: I460d549f9435ee2255f62f9bec808a3e8fbf1c28
diff --git a/android/androidmk.go b/android/androidmk.go
index 18b26d9..fc34471 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -72,7 +72,9 @@
 		androidMkModulesList = append(androidMkModulesList, module)
 	})
 
-	sort.Sort(ModulesByName{androidMkModulesList, ctx})
+	sort.SliceStable(androidMkModulesList, func(i, j int) bool {
+		return ctx.ModuleName(androidMkModulesList[i]) < ctx.ModuleName(androidMkModulesList[j])
+	})
 
 	transMk := PathForOutput(ctx, "Android"+String(ctx.Config().productVariables.Make_suffix)+".mk")
 	if ctx.Failed() {
diff --git a/android/module.go b/android/module.go
index d2f84ce..303d8c6 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1619,27 +1619,6 @@
 	}
 }
 
-type ModulesByName struct {
-	slice []blueprint.Module
-	ctx   interface {
-		ModuleName(blueprint.Module) string
-		ModuleSubDir(blueprint.Module) string
-	}
-}
-
-func (s ModulesByName) Len() int { return len(s.slice) }
-func (s ModulesByName) Less(i, j int) bool {
-	mi, mj := s.slice[i], s.slice[j]
-	ni, nj := s.ctx.ModuleName(mi), s.ctx.ModuleName(mj)
-
-	if ni != nj {
-		return ni < nj
-	} else {
-		return s.ctx.ModuleSubDir(mi) < s.ctx.ModuleSubDir(mj)
-	}
-}
-func (s ModulesByName) Swap(i, j int) { s.slice[i], s.slice[j] = s.slice[j], s.slice[i] }
-
 // Collect information for opening IDE project files in java/jdeps.go.
 type IDEInfo interface {
 	IDEInfo(ideInfo *IdeInfo)