Index: sites/all/modules/swfupload/js/swfupload_widget.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- sites/all/modules/swfupload/js/swfupload_widget.js	(revision 25849)
+++ sites/all/modules/swfupload/js/swfupload_widget.js	(revision )
@@ -1,5 +1,5 @@
 /**
- * 
+ *
  */
 function SWFU(id, settings) {
   var ref = {};
@@ -23,7 +23,7 @@
   ref.messages_timeout;
 
   /**
-   * 
+   *
    */
   ref.init = function() {
     ref.settings = settings;
@@ -80,14 +80,14 @@
   };
 
   /**
-   * 
+   *
    */
   ref.newSWFUpload = function() {
     ref.swfu = new SWFUpload(ref.settings);
   };
 
   /**
-   * 
+   *
    */
   ref.ajaxResponse = function(result) {
     var result = Drupal.parseJson(result);
@@ -108,7 +108,7 @@
 
   /**
    * Custom function for when the initialization is complete
-   * This event handler is defined in swfupload.module as an instance callback function 
+   * This event handler is defined in swfupload.module as an instance callback function
    */
   ref.initComplete = function(result) {
     ref.createWrapper(result.instance.name);
@@ -131,10 +131,40 @@
    * For all files in the stack, a file element will be added to the wrapper using ref.addFileItem().
    */
   ref.addStoredFiles = function() {
+
+	// Sort by weight
+	var tempFiles = new Array();
-    for(var i in ref.upload_stack) {
-      if (ref.upload_stack[i] == 0) {
-        break;
-      };
+	for(var i in ref.upload_stack) {
+		if (ref.upload_stack[i] == 0) {
+      break;
+    };
+
+    weight = ref.upload_stack[i]['weight'];
+    if (weight == null) {
+      tempFiles.push(ref.upload_stack[i])
+    }
+    else {
+      tempFiles[weight] = ref.upload_stack[i];
+    }
+	};
+
+	for(var i in tempFiles) {
+		  fid = tempFiles[i]['fid']
+	      ref.upload_stack[fid].id = fid;
+	      ref.upload_stack[fid].fid = fid;
+	      ref.upload_stack[fid].extension = ref.getExtension(ref.upload_stack[fid].filename);
+	      ref.addFileItem(ref.upload_stack[fid]);
+
+	      // Adjust the bytes in the stack.
+	      ref.upload_stack_size += parseInt(ref.upload_stack[fid].filesize);
+	};
+
+	/*
+    for(var i in ref.upload_stack) {
+
+      if (ref.upload_stack[i] == 0) {
+        break;
+      };
       ref.upload_stack[i].id = i;
       ref.upload_stack[i].fid = i;
       ref.upload_stack[i].extension = ref.getExtension(ref.upload_stack[i].filename);
@@ -142,7 +172,9 @@
 
       // Adjust the bytes in the stack.
       ref.upload_stack_size += parseInt(ref.upload_stack[i].filesize);
+
     };
+	*/
     ref.addEventHandlers('drag_enable');
   };
 
@@ -155,7 +187,7 @@
     var element;
 
     if (ref.num_elements > 1 && ref.instance.type == 'table') {
-      // First we'll check if we need to create a header 
+      // First we'll check if we need to create a header
       for (var name in ref.instance.elements) {
         if (ref.instance.elements[name].title) {
            use_header = true;
@@ -176,12 +208,12 @@
 
       Drupal.settings.tableDrag['swfupload_file_wrapper-' + field_name] = {};
     };
-  };    
+  };
 
   /**
    * Creates or changes a tablerow
    * @param header Boolean Wheter or not the tablerow should contain th's. If sety to false, td's will be generated.
-   * @param file Object A completed file object 
+   * @param file Object A completed file object
    *   - If this is not set, a row is created including the progressbar, which replaces the td's with contains_progressbar set to true.
    *   - If file is set, the progressbar will be replaced with the appropriate td's
    */
@@ -228,7 +260,7 @@
       input = $((element.type == 'textarea' ? '<textarea />' : '<input type="' + element.type + '" />')).attr({'name':name +'_' + fid, 'id':'edit-' + name + '_' + fid}).addClass('form-' + element.type);
 
       if (header) {
-        // Keep track of colspans 
+        // Keep track of colspans
         if (colspan > 0) colspan--;
         if (element.colspan) {
           colspan = element.colspan;
@@ -300,7 +332,7 @@
       progress_td.attr({'colSpan':progress_td_counter});
     };
 
-    // Update the checked value of all added checkboxes 
+    // Update the checked value of all added checkboxes
     tr.find('input.checkbox').each(function() {
       $(this).attr('checked', $(this).hasClass('checked'));
     });
@@ -320,7 +352,7 @@
    * A file has been selected. This function creates the markup referring to the new file object
    */
   ref.addFileItem = function(file) {
-    // Create the markup for the new file by copying the hidden template 
+    // Create the markup for the new file by copying the hidden template
     var new_file_obj = ref.wrapper_obj.find('.hidden').clone().attr({'id':file.id}).appendTo(ref.wrapper_obj);
     var dom_obj, value, elem_value;
 
@@ -346,7 +378,7 @@
           dom_obj.html(value).show();
         };
 
-        // If the inputfield is hidden, we're dealing with a string. 
+        // If the inputfield is hidden, we're dealing with a string.
         // Look if there is a span of which the text can be replaced
         if (dom_obj.css('display') == 'none') {
           dom_obj.parent().find('span').text(value);
@@ -419,20 +451,20 @@
         // Attach the tabledrag behavior
         // This will we only executed once.
         Drupal.attachBehaviors(ref.wrapper_obj);
-    
+
         $('tbody tr', ref.wrapper_obj).not('.hidden, .tabledrag-handle-swfupload-moved').each(function() {
-    
+
           if (!$('a.tabledrag-handle', $(this)).size()) {
             Drupal.tableDrag[ref.wrapper_id].makeDraggable(this);
           };
-    
+
           $('a.tabledrag-handle', $(this)).not('.tabledrag-handle-swfupload-moved').each(function() {
             $(this).appendTo($(this).parents('tr').addClass('tabledrag-handle-swfupload-moved').find('td.drag div.wrapper')).bind('mousedown', function() {
               $(this).parents('tr').addClass('dragging');
             });
           });
         });
-    
+
         $(document).unbind('mouseup', ref.tableDragStop).bind('mouseup', ref.tableDragStop);
         break;
 
@@ -532,7 +564,7 @@
   };
 
   /**
-   * Responds on file queue errors 
+   * Responds on file queue errors
    */
   ref.fileQueueError = function(file, code, message) {
     switch (code) {
@@ -728,27 +760,34 @@
     var old_upload_stack = ref.upload_stack;
     var total_size = 0;
     ref.upload_stack = {};
+    weight = 0
 
     ref.wrapper_obj.find('.processed').each(function() {
       fid = $(this).attr('id');
 
       // If no file is secified, the function is called after sorting
       // There are no new values so the file object is not needed
-      // We only need to change the order of the stack 
+      // We only need to change the order of the stack
       if (!file) {
         ref.upload_stack[fid] = old_upload_stack[fid];
+		    ref.upload_stack[fid]['weight'] = weight
       }
       else {
         ref.upload_stack[fid] = {filename:file.filename || file.name, fid:fid};
+        ref.upload_stack[fid]['weight'] = weight
+
         total_size += parseInt(file.size);
         for (var name in ref.instance.elements) {
           input_field = $('#edit-' + name + '_' + fid);
           if (input_field.size() !== 0) {
-            ref.upload_stack[fid][name] = (input_field.attr('type') == 'checkbox') ? input_field.attr('checked') : input_field.val();
+            ref.upload_stack[fid][name]  = (input_field.attr('type') == 'checkbox') ? input_field.attr('checked') : input_field.val();
           };
         };
       };
+
+	  weight += 1;
     });
+
     ref.upload_stack_size = total_size;
     ref.upload_stack_length = ref.objectLength(ref.upload_stack);
     ref.upload_stack_obj.val(ref.toJson(ref.upload_stack));
@@ -860,7 +899,7 @@
   };
 
   /**
-   * 
+   *
    */
   ref.getExtension = function(file_name) {
     return file_name.substring(file_name.lastIndexOf('.') + 1).toLowerCase();
@@ -899,7 +938,7 @@
     temp_arr = temp_arr.reverse();
     for (var i in temp_arr) {
       temp_obj[temp_arr[i].key] = temp_arr[i].data;
-    };    
+    };
     return temp_obj;
   };
 
Index: sites/all/modules/swfupload/swfupload_widget.inc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- sites/all/modules/swfupload/swfupload_widget.inc	(revision 25849)
+++ sites/all/modules/swfupload/swfupload_widget.inc	(revision )
@@ -55,6 +55,7 @@
             'description' => $file['description'],
             'alt' => $file['alt'],
             'title' => $file['title'],
+			'weight' => $file['weight'],
           ),
         )
       );
@@ -86,6 +87,7 @@
             'alt' => $tmp_file['data']['alt'],
             'title' => $tmp_file['data']['title'],
             'list' => $tmp_file['list'],
+ 			'weight' => $tmp_file['data']['weight'],
           );
 
           // If we're dealing with an image, create a thumbpath
Index: sites/all/modules/swfupload/swfupload.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- sites/all/modules/swfupload/swfupload.module	(revision 25849)
+++ sites/all/modules/swfupload/swfupload.module	(revision )
@@ -180,6 +180,7 @@
         'max_queue_size' => ($field['widget']['max_filesize_per_node'] ? $field['widget']['max_filesize_per_node'] : 0),
       ),
     );
+
     drupal_add_js('misc/tabledrag.js', 'core');
     drupal_add_js("$path/js/swfupload_widget.js");
     drupal_add_js($settings, 'setting');
@@ -348,4 +349,4 @@
   else {
     return str_replace(array('\x3c', '\x3e', '\x26'), array('\u003c', '\u003e', '\u0026'), drupal_to_js($var));
   }
-}
+}
\ No newline at end of file
