I have an array and trying to pass it to the view.
$products = Product::orderBy('sort_order')->get()->keyBy('id')->toArray();
That returns in php
$products = [
2 => [
"id"=2,
"title"="Product2",
"sort_order"=1,
],
1 => [
"id"=1,
"title"="Product1",
"sort_order"=2,
]
]
However in blade the order of the array is displayed as:
$products = [
1 => [
"id"=1,
"title"="Product1",
"sort_order"=2,
],
2 => [
"id"=2,
"title"="Product2",
"sort_order"=1,
]
]
How can I tackle this?