diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Query.php b/core/lib/Drupal/Core/Config/Entity/Query/Query.php
index 4566cb11d5..2500ab5660 100644
--- a/core/lib/Drupal/Core/Config/Entity/Query/Query.php
+++ b/core/lib/Drupal/Core/Config/Entity/Query/Query.php
@@ -89,7 +89,14 @@ public function execute() {
       $direction = $sort['direction'] == 'ASC' ? -1 : 1;
       $field = $sort['field'];
       uasort($result, function ($a, $b) use ($field, $direction) {
-        return ($a[$field] <= $b[$field]) ? $direction : -$direction;
+        $properties = explode('.', $field);
+        foreach ($properties as $property) {
+          if (isset($a[$property]) && isset($b[$property])) {
+            $a = $a[$property];
+            $b = $b[$property];
+          }
+        }
+        return ($a <= $b) ? $direction : -$direction;
       });
     }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
index 8dc101a465..5956a2a28e 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
@@ -565,6 +565,11 @@ public function testDotted() {
       ->condition('array.level1.level2', 3)
       ->execute();
     $this->assertResults(['5']);
+    // Test dotted sorting.
+    $this->queryResults = $this->factory->get('config_query_test')
+      ->sort('array.level1.level2', 'DESC')
+      ->execute();
+    $this->assertResults(['5', '2', '4', '1', '3']);
     // Make sure that values on the wildcard level do not match if there are
     // sub-keys defined. This must not find anything even if entity 2 has a
     // top-level key number with value 41.
