Dynamic Menu not showing items in order storted

Here’s my code. It is not showing menu items in order by master_item, item_number although I"ve specified that in my query. It seems to be sorting in descending order. 1.3, 1.2, 1.0. All of my numeric fields (id, master_item, and item_number) are INT 11. I have tried changing my query to include DESC. I have removed all indexes except ID at the database level. I change all item_number values to zero; thinking it might do something different - it does not.

[SIZE=13px]//2018-01299:bh Apps with link not called from elsewhere that user has permission to run[/SIZE]
[SIZE=13px]$array1= array();[/SIZE]
[SIZE=13px]sc_select(rs, "SELECT id FROM app_menu WHERE called_from = ‘’ AND link IN (SELECT app_name FROM sec_groups_apps WHERE group_id = ‘1’ AND priv_access = ‘Y’) ") ;[/SIZE]
[SIZE=13px] $array1[] = $rs->fields[0];[/SIZE]
[SIZE=13px] $rs->MoveNext();[/SIZE]

[SIZE=13px]//2018-0129:bh Master of linked items - only those with a master greater than 1 - has duplicates[/SIZE]
[SIZE=13px]$array2= array() ;[/SIZE]
[SIZE=13px]foreach($array1 as $k => $linked_item){[/SIZE]
[SIZE=13px]sc_select(rs, “SELECT master_item FROM app_menu WHERE id = $linked_item AND master_item != 0”) ; [/SIZE]
[SIZE=13px]$array2[] = $rs->fields[0];[/SIZE]

[SIZE=13px]$result = array_merge($array1, $array2);[/SIZE]
[SIZE=13px]/print_r($result); //Show me the linked array/[/SIZE]

[SIZE=13px]foreach($result as $m => $item_id) {[/SIZE]
[SIZE=13px]$sql = “SELECT id, master_item, description, link, hint, item_number FROM app_menu WHERE id = $item_id ORDER BY master_item, item_number”;[/SIZE]
[SIZE=13px]sc_lookup(ds, $sql);[/SIZE]

[SIZE=13px]foreach({ds} as $arr_menu_item)[/SIZE]
[SIZE=13px]$menu_item = “item_”.$arr_menu_item[0];[/SIZE]

[SIZE=13px]if($arr_menu_item[1] == 0)[/SIZE]
[SIZE=13px]$master_id = “”;[/SIZE]
[SIZE=13px]$master_id = “item_”.$arr_menu_item[1]; [/SIZE]

[SIZE=13px]sc_appmenu_add_item(“menu”, $menu_item, $master_id, $arr_menu_item[2], $arr_menu_item[3], “”, “”, $arr_menu_item[4], “”);[/SIZE]
[SIZE=13px]} //for each item[/SIZE]
[SIZE=13px]} //for each result[/SIZE]

(Wish I had updated this when I was working on it … have the menu working as expected … sorts as expected … but the only note that I can find that I wrote is this … )

//THIS WORKS! Sorts as expected
$sql = “SELECT id, parent_id, label, link, hint, target FROM sec_group_menu WHERE group_id IN (SELECT group_id FROM sec_users_groups WHERE login = ‘[usr_login]’) ORDER BY parent_id, node_order, label”;

Found it! The issue was that I had a unique index on the LABEL column