Skip to content
Snippets Groups Projects
Commit 002ea78d authored by Petar Bašić's avatar Petar Bašić Committed by Volodymyr Mostepaniuk
Browse files

Issue #3182120 by petar_basic: Order of sub elements is not conserved if weights are the same

parent 038a9077
No related branches found
No related tags found
No related merge requests found
...@@ -206,6 +206,12 @@ class CustomElement implements CacheableDependencyInterface { ...@@ -206,6 +206,12 @@ class CustomElement implements CacheableDependencyInterface {
public function getSortedSlotsByName() { public function getSortedSlotsByName() {
$slots = $this->getSlots(); $slots = $this->getSlots();
foreach ($slots as $slot_key => &$entries) { foreach ($slots as $slot_key => &$entries) {
$i = 0;
$count = count($entries);
foreach ($entries as &$entry) {
$entry['weight'] = floor($entry['weight'] * 1000) + $i / $count;
$i++;
}
usort($entries, 'Drupal\Component\Utility\SortArray::sortByWeightElement'); usort($entries, 'Drupal\Component\Utility\SortArray::sortByWeightElement');
} }
return $slots; return $slots;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment