diff -u b/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php b/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php --- b/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php +++ b/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php @@ -114,7 +114,7 @@ $function = $direction == 'ASC' ? 'min' : 'max'; $expression = "$function($sql_alias)"; $sqlQuery->addExpression($expression, "order_by_{$property}_$direction"); - $sqlQuery->orderBy($expression); + $sqlQuery->orderBy($expression, $direction); } } } diff -u b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php --- b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php @@ -201,7 +201,14 @@ // 13 red tr // 15 red tr $this->assertResult(8, 12, 4, 2, 3, 10, 11, 14, 15, 6, 7, 1, 9, 13, 5); - + $query = $factory->get('test_entity') + ->sort("$figures.color", 'DESC') + ->sort("$greetings.langcode", 'DESC') + ->sort('ftid', 'DESC'); + $count_query = clone $query; + $this->assertEqual(15, $count_query->count()->execute()); + $this->queryResults = $query->execute(); + $this->assertResult(15, 13, 7, 5, 11, 9, 3, 1, 14, 6, 10, 2, 12, 4, 8); // Now update the 'merhaba' string to xsiemax which is not a meaningful // word but allows us to test revisions and string operations. $ids = $factory->get('test_entity')