diff --git a/app/devices/device_profile_edit.php b/app/devices/device_profile_edit.php
index b58ad85b82..2d20259db2 100644
--- a/app/devices/device_profile_edit.php
+++ b/app/devices/device_profile_edit.php
@@ -173,7 +173,22 @@
$sql = "select * from v_device_profile_keys ";
$sql .= "where device_profile_uuid = :device_profile_uuid ";
//$sql .= "and domain_uuid = '".$domain_uuid."' ";
- $sql .= "order by profile_key_id asc";
+ $sql .= "order by ";
+ $sql .= "profile_key_vendor asc, ";
+ $sql .= "case profile_key_vendor ";
+ $sql .= "when 'line' then 1 ";
+ $sql .= "when 'memory' then 2 ";
+ $sql .= "when 'programmable' then 3 ";
+ $sql .= "when 'expansion' then 4 ";
+ $sql .= "when 'expansion-1' then 5 ";
+ $sql .= "when 'expansion-2' then 6 ";
+ $sql .= "else 100 end, ";
+ if ($db_type == "mysql") {
+ $sql .= "profile_key_id asc ";
+ }
+ else {
+ $sql .= "cast(profile_key_id as numeric) asc ";
+ }
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['device_profile_uuid'] = $device_profile_uuid;
$database = new database;
@@ -281,6 +296,7 @@
echo "
".$text['label-device_key_icon']." | \n";
echo " | \n";
echo " \n";
+//view_array($device_profile_keys);
$x = 0;
foreach($device_profile_keys as $row) {
echo " \n";
@@ -289,18 +305,19 @@
echo " \n";
echo " | \n";
echo " \n";
echo " | \n";