diff --git a/core/lib/Drupal/Core/Render/Element.php b/core/lib/Drupal/Core/Render/Element.php index 53886b6..ac9f066 100644 --- a/core/lib/Drupal/Core/Render/Element.php +++ b/core/lib/Drupal/Core/Render/Element.php @@ -85,15 +85,15 @@ public static function children(array &$elements, $sort = FALSE) { if ($key === '' || $key[0] !== '#') { if (is_array($value)) { if (isset($value['#weight'])) { - $child_weights[$key] = $value['#weight']; + $weight = $value['#weight']; $sortable = TRUE; } else { - $child_weights[$key] = 0; + $weight = 0; } - // Add a small number between 0 and 1 to keep the order of insertion - // of equal weight elements. - $child_weights[$key] += $i / $count; + // Supports weight with up to three digit precision and conserve + // the insertion order. + $child_weights[$key] = floor($weight * 1000) + $i / $count; } // Only trigger an error if the value is not null. // @see http://drupal.org/node/1283892