diff --git a/include/simpleplugin/attributes/class_SetAttribute.inc b/include/simpleplugin/attributes/class_SetAttribute.inc
index be39536ac2ff937b848e6be1a9dab21ff5f2454a..b8fb3cf19889585d71cf4b7860975a8fd90ed57e 100644
--- a/include/simpleplugin/attributes/class_SetAttribute.inc
+++ b/include/simpleplugin/attributes/class_SetAttribute.inc
@@ -301,10 +301,15 @@ class SetAttribute extends Attribute
 
   function computeLdapValue ()
   {
-    sort($this->value);
+    $this->sortValues();
     return array_values($this->value);
   }
 
+  protected function sortValues ()
+  {
+    sort($this->value);
+  }
+
   public function htmlIds (): array
   {
     $id = $this->getHtmlId();
@@ -427,9 +432,7 @@ class OrderedArrayAttribute extends SetAttribute
 
   function computeLdapValue ()
   {
-    if (!$this->order) {
-      sort($this->value);
-    }
+    $this->sortValues();
     $ldapValue = [];
     foreach ($this->value as $key => $value) {
       $ldapValue[] = $this->writeValue($key, $value);
@@ -437,6 +440,13 @@ class OrderedArrayAttribute extends SetAttribute
     return $ldapValue;
   }
 
+  protected function sortValues ()
+  {
+    if (!$this->order) {
+      sort($this->value);
+    }
+  }
+
   protected function loadAttrValue (array $attrs)
   {
     if (isset($attrs[$this->getLdapName()]["count"])) {
diff --git a/include/simpleplugin/class_dialogAttributes.inc b/include/simpleplugin/class_dialogAttributes.inc
index dd5f3f57bd128bf259085f7d5edbcb1cab9d25c8..5d33fc03dacd27d361c5a6e7c51480e9f3f4f3ef 100644
--- a/include/simpleplugin/class_dialogAttributes.inc
+++ b/include/simpleplugin/class_dialogAttributes.inc
@@ -362,6 +362,11 @@ class GenericDialogAttribute extends DialogAttribute
     unset($this->value[$row]);
   }
 
+  protected function sortValues ()
+  {
+    asort($this->value);
+  }
+
   function getDisplayValues ()
   {
     foreach (array_keys($this->value) as $i) {