diff --git a/includes/export.inc b/includes/export.inc
index 0b2ef46..098377f 100644
--- a/includes/export.inc
+++ b/includes/export.inc
@@ -867,8 +867,11 @@ function ctools_var_export($var, $prefix = '') {
     }
     else {
       $output = "array(\n";
-      foreach ($var as $key => $value) {
-        $output .= $prefix . "  " . ctools_var_export($key) . " => " . ctools_var_export($value, $prefix . '  ') . ",\n";
+      $var_sorted = $var;
+      if (ksort($var_sorted)) {
+        foreach ($var_sorted as $key => $value) {
+          $output .= $prefix . "  " . ctools_var_export($key) . " => " . ctools_var_export($value, $prefix . '  ') . ",\n";
+        }
       }
       $output .= $prefix . ')';
     }
