diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index fbdb14229d501fe350a2b70c425a60f2ca92d21a..c97739963b6f66316e75d9fb48455d68988c1988 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -950,12 +950,14 @@ class DynamicFormEntry extends VerySimpleModel {
 
                 $a->save();
             }
-            // Sort the form the way it is declared to be sorted
-            if ($this->_fields)
-                usort($this->_fields,
-                    function($a, $b) {
-                        return $a->get('sort') - $b->get('sort');
-                });
+        }
+
+        // Sort the form the way it is declared to be sorted
+        if ($this->_fields) {
+            uasort($this->_fields,
+                function($a, $b) {
+                    return $a->get('sort') - $b->get('sort');
+            });
         }
     }