PHP Order array based on elements dependency
问题 Fairly hard one to explain, but effectively I've got an array of items which have IDs, of which can contain a list of IDs for other array items. for example $items = [ [id: 'one', deps: ['three']], [id: 'two'], [id: 'three', deps: ['four', 'two']], [id: 'four'] ]; So as you can see here, one depends on three, and three depends on four and two. I need to get a new array, that contains these items in order - so that the dependencies are listed in order. So the above array would convert into