Goal
Sort a list of items ensuring that each item is listed after its specified dependencies.
Input
An array of arrays of integers, where each integer specifies the 0-based or 1-based index of another item that this item must come after. The input may be an array or string or anything else human readable.
For example, a 0-based input:
[
[ 2 ], // item 0 comes after item 2
[ 0, 3 ], // item 1 comes after item 0 and 3
[ ], // item 2 comes anywhere
[ 2 ] // item 3 comes after item 2
]
Assume there are no circular dependencies, there is always at least one valid order.
Output
The numbers in order of dependency. An ambiguous order does not have to be deterministic. The output may be an array or text or anything else human readable.
Only one order should be given in the output, even where there are multiple valid orders.
Possible outputs for the above input include:
[ 2, 3, 0, 1 ]
[ 2, 0, 3, 1 ]
Scoring
A function or program that completes this in the least number of bytes wins the glory of acceptance. The deadline is in 6 days.