如何在laravel php中对多维数组中选择的集合进行排序
我想在嵌套数组集合中按cu\u customer\u shortname排序,但似乎找不到任何方法。下面是我的数组列表示例如何在laravel php中对多维数组中选择的集合进行排序,php,laravel,Php,Laravel,我想在嵌套数组集合中按cu\u customer\u shortname排序,但似乎找不到任何方法。下面是我的数组列表示例 {#1811 ▼ +"co_group_id": "ADUKO" +"co_description": "ADUKO" +"co_customer_id": "038" +"co_active_sts": "1
{#1811 ▼
+"co_group_id": "ADUKO"
+"co_description": "ADUKO"
+"co_customer_id": "038"
+"co_active_sts": "1"
+"irel__h_d_rel_group_customer": array:3 [▼
0 => {#1812 ▼
+"ID": "5"
+"gc_group_id": "ADUKO"
+"gc_customer_id": "038"
+"irel__h_d_customer_master": {#1813 ▶}
}
1 => {#1814 ▼
+"ID": "6"
+"gc_group_id": "ADUKO"
+"gc_customer_id": "044"
+"irel__h_d_customer_master": {#1815 ▼
+"cu_customer_ID": "044"
+"cu_customer_Shortname": "JPEN" <------ Sort this shortname
}
}
]
我的代码没有返回任何错误,但我的列表仍然存在,并且没有按cu\u customer\u Shortname进行排序检查此帖子@GiacomoM感谢您的访问,但我得到了另一个子数组,它与您给出的帖子的方法不同。您可以发布最终结果排序应该做什么。@abower方法相同,只需在闭包函数中导航子数组检查此帖子@GiacomoM感谢您的访问,但我得到了另一个子数组,它与您提供的帖子的方法不同。您可以发布最终结果排序应该做什么。@如果方法相同,只需在闭包函数中导航子数组即可
$groupList = $contents->data->groupList;
$order = $groupList->irel__h_d_rel_group_customer; //arrayList
$collection = new \Illuminate\Support\Collection($groupList); //collection
$sorted = $collection->SortByDesc('irel__h_d_customer_master.cu_customer_Shortname'); // sorted by cu_customer_shortname