diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php
index 2ccbf94..df012ff 100644
--- a/core/lib/Drupal/Core/Config/ConfigImporter.php
+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -373,13 +373,11 @@ protected function createExtensionChangelist() {
     // Work out what modules to install and uninstall.
     $uninstall = array_diff(array_keys($current_extensions['module']), array_keys($new_extensions['module']));
     $install = array_diff(array_keys($new_extensions['module']), array_keys($current_extensions['module']));
-    // Sort the module list by their weights. So that dependencies
-    // are uninstalled last.
-    asort($module_list);
+
+    $module_list = $this->sortModulesForUninstall($module_list);
     $uninstall = array_intersect(array_keys($module_list), $uninstall);
-    // Sort the module list by their weights (reverse). So that dependencies
-    // are installed first.
-    arsort($module_list);
+
+    $module_list = $this->sortModulesForInstall($module_list);
     $install = array_intersect(array_keys($module_list), $install);
 
     // Work out what themes to enable and to disable.
@@ -399,6 +397,70 @@ protected function createExtensionChangelist() {
   }
 
   /**
+   * Sorts the module list in a consistent order for installation.
+   *
+   * Sort the module list by their weights (reverse). So that dependencies
+   * are uninstalled last. Modules of the same weight are sorted in reverse
+   * alphabetical order. The use of array_multisort() is to ensure a
+   * consistent order when module weights are equal. For example an array like
+   * <code>
+   *   array(
+   *     'actions' => 0,
+   *     'ban' => 0,
+   *     'options' => -2,
+   *     'text' => -1,
+   *   );
+   * </code>
+   * will result in the following sort order:
+   * 0   options
+   * 1   text
+   * 2 0 ban
+   * 2 1 actions
+   *
+   * @param array $module_list
+   *   The list of modules keyed by name with a value of weight.
+   *
+   * @return array
+   *   The list of modules sorted by weight then name.
+   */
+  protected function sortModulesForUninstall($module_list) {
+    array_multisort(array_values($module_list), SORT_ASC, array_keys($module_list), SORT_DESC, $module_list);
+    return $module_list;
+  }
+
+  /**
+   * Sorts the module list in a consistent order for installation.
+   *
+   * Sort the module list by their weights (reverse). So that dependencies
+   * are installed first. Modules of the same weight are sorted in
+   * alphabetical order. The use of array_multisort() is to ensure a
+   * consistent order when module weights are equal. For example an array like
+   * <code>
+   *   array(
+   *     'actions' => 0,
+   *     'ban' => 0,
+   *     'options' => -2,
+   *     'text' => -1,
+   *   );
+   * </code>
+   * will result in the following sort order:
+   * 0 0 actions
+   * 0 1 ban
+   * 1   text
+   * 2   options
+   *
+   * @param array $module_list
+   *   The list of modules keyed by name with a value of weight.
+   *
+   * @return array
+   *   The list of modules sorted by weight then name.
+   */
+  protected function sortModulesForInstall($module_list) {
+    array_multisort(array_values($module_list), SORT_DESC, array_keys($module_list), SORT_ASC, $module_list);
+    return $module_list;
+  }
+
+  /**
    * Gets a list changes for extensions.
    *
    * @param string $type
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
index 53954c7..92b7656 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
@@ -152,8 +152,8 @@ function testImport() {
     // Ensure installations and uninstallation occur as expected.
     $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array());
     $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', array());
-    $expected = array('ban', 'action', 'text', 'options');
-    $this->assertIdentical($expected, $installed, 'Ban, Action, Text and Options modules installed in the correct order.');
+    $expected = array('action', 'ban', 'text', 'options');
+    $this->assertIdentical($expected, $installed, 'Action, Ban, Text and Options modules installed in the correct order.');
     $this->assertTrue(empty($uninstalled), 'No modules uninstalled during import');
 
     // Verify that the action.settings configuration object was only written
@@ -207,7 +207,7 @@ function testImport() {
     $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array());
     $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', array());
     $expected = array('options', 'text', 'ban', 'action');
-    $this->assertIdentical($expected, $uninstalled, 'Options, Text, Action and Ban modules uninstalled in the correct order.');
+    $this->assertIdentical($expected, $uninstalled, 'Options, Text, Ban and Action modules uninstalled in the correct order.');
     $this->assertTrue(empty($installed), 'No modules installed during import');
 
     $theme_info = \Drupal::service('theme_handler')->listInfo();
