Guest User

Untitled

a guest
Dec 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. // In this sorting function, we have three indices in our array
  2. // a[0] - the name of the injection
  3. // a[1] - the name of an injection that THIS injection should be before
  4. // a[2] - the name of an injection that THIS injection should be after
  5.  
  6. // When given an array:
  7. // [['b', 'c', null], ['a','b', null], ['d', null, 'c'], ['c', null, null], ['e', null, 'd']];
  8.  
  9. // Then the output from this array should look like:
  10. // [['a','b', null], ['b', 'c', null], ['c', null, null], ['d', null, 'c'], ['e', null, 'd']];
  11.  
  12. // We are assuming:
  13. // The injection should either have a before OR an after, not both
  14. // If an injection utilizes the same name/object for a before or after target, then the injections should be considered to be un-ordered within that set
  15.  
  16. // Here are the rules for the sort:
  17. // #1 an injection with a before target should appear before any other injection
  18. // and that injection should appear before it's named target
  19.  
  20. // #2 an injection with an after target should appear after any other injection
  21. // and that injection should appear after it's named target
  22.  
  23. var injections = [['b', 'c', null], ['a','b', null], ['d', null, 'c'], ['c', null, null], ['e', null, 'd']];
Add Comment
Please, Sign In to add comment