--- includes/flag.export.inc.orig
+++ includes/flag.export.inc
@@ -41,8 +41,11 @@ function flag_export_flags($flags = array(), $module = '', $indent = '') {
     // Remove the flag ID.
     unset($new_flag['fid']);
 
+    // Sort the types array for consistent exports
+    sort($new_flag['types']);
+
     $output .= $indent . '// Exported flag: "'. check_plain($flag->get_title()) . '"' . ".\n";
-    $output .= $indent . '$flags[] = ' . (function_exists('ctools_var_export') ? ctools_var_export($new_flag, $indent) : var_export($new_flag, TRUE)) . ";\n";
+    $output .= $indent . '$flags[' . "'" . $new_flag['name'] . "'] = " . (function_exists('ctools_var_export') ? ctools_var_export($new_flag, $indent) : var_export($new_flag, TRUE)) . ";\n";
   }
   $output .= $indent . 'return $flags;';
   return $output;
