Patch #505528 by Damien Tournoud: JS files of the same weight are not included in the order of the calls.

From: damz <damz@damz-dev.local>


---
 common.inc |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git includes/common.inc includes/common.inc
index 0e275fd..dced29c 100644
--- includes/common.inc
+++ includes/common.inc
@@ -2766,6 +2766,10 @@ function drupal_add_js($data = NULL, $options = NULL) {
   // Preprocess can only be set if caching is enabled.
   $options['preprocess'] = $options['cache'] ? $options['preprocess'] : FALSE;
 
+  // Tweak the weight so that files of the same weight are included in the
+  // order of the calls to drupal_add_js().
+  $options['weight'] += count($javascript) / 1000;
+
   if (isset($data)) {
     // Add jquery.js and drupal.js, as well as the basePath setting, the
     // first time a Javascript file is added.
