diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 5d1396a..bcdcc1e 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -122,6 +122,36 @@ function _block_rehash($theme = NULL) { } /** + * Provides block comparison function. + * + * @param $first + * First block object to compare. + * + * @param $second + * Second block object to compare. + */ + function _block_cmp($first, $second) { + + // Compare weight first. + if ($first->weight < $second->weight) { + return -1; + } + else if ($first->weight > $second->weight) { + return 1; + } + + // Compare id in the reverse order then. + if ($first->id < $second->id) { + return 1; + } + else if ($first->id > $second->id) { + return -1; + } + + return 0; +} + +/** * Initializes blocks for installed themes. * * @param $theme_list diff --git a/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php index 293f088..a0fc470 100644 --- a/core/modules/block/src/BlockListBuilder.php +++ b/core/modules/block/src/BlockListBuilder.php @@ -100,7 +100,7 @@ public function load() { $entities = _block_rehash($this->theme); // Sort the blocks using \Drupal\block\Entity\Block::sort(). - uasort($entities, array($this->entityType->getClass(), 'sort')); + uasort($entities, '_block_cmp'); return $entities; }