Массив вида
[
[
"name1" => ["value" => "v", "depends" => ["name3, name 5"]
],
[
"name2" => ["value" => "v", "depends" => ["name1"]
],
[
"name3" => ["value" => "v", "depends" => ["name5"]
],
[
"name4" => ["value" => "v", "depends" => ["name1, name 2"]
],
[
"name5" => ["value" => "v", "depends" => []
],
]
Привести к виду
[
[
"name5" => ["value" => "v", "depends" => []
],
[
"name3" => ["value" => "v", "depends" => ["name5"]
],
[
"name1" => ["value" => "v", "depends" => ["name3, name 5"]
],
[
"name2" => ["value" => "v", "depends" => ["name1"]
],
[
"name4" => ["value" => "v", "depends" => ["name1, name 2"]
],
]
Как правильнее сделать?