How can I test that some specific element comes before another specific element in an array?

Viewed 916

I had a problem whereby a list of jobs, each represented by a character "a", "b", "c" etc, had to be sorted given that some of them depended on other jobs. So if job "a" depended on "b", and "b" and "c" didn't depend on any job, the list 'abc' would be sorted as 'bac', simple.

My problem is I want to write a test to check that jobs come after the jobs they depend on in the output array.

Example

If job "c" depends on job "f", how can I test that "f" is before "c" in

array = ["a", "b", "f", "c", "d", "e"]
3 Answers
Related