diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index b1917f42ee8..e144ae5c569 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -502,8 +502,6 @@ class FormAccounting extends Form
return -1;
}
- ksort($aux_account);
-
$this->db->free($resql);
// Auxiliary user account
@@ -526,6 +524,8 @@ class FormAccounting extends Form
}
$this->db->free($resql);
+ ksort($aux_account);
+
if ($usecache) {
$this->options_cache[$usecache] = $aux_account;
}