docs: function sortDependencies( dependencies ) {
  
      // Build the list of keys.
      var keys = [];
      for ( var i = 0; i < dependencies.length; i++ ) {
          keys.push( dependencies[i][0] );
      }
  
      var unsorted = dependencies.slice();    // Entries not yet sorted.
      var sorted_keys = [];                   // Keys already sorted.
      var sorted = [];                        // Entries already sorted.
  
      // Each pass through the map should sort at least one item.
      // This gives us a maximum number of passes as n*(n+1) / 2.
      var max_pass = ( dependencies.length * ( dependencies.length + 1 ) ) / 2;
      for ( var i = 0; i < max_pass; i++ ) {
          // On each pass, we pull out anything that has no dependencies,
          // is depend on an item which has already been sorted, or is
          // dependent on something not in this map.
          var dependency = unsorted.shift();
          var key = dependency[0];
          var dependsOn = dependency[1];
          if ( dependsOn === null
              || sorted_keys.indexOf( dependsOn ) >= 0
              || keys.indexOf( dependsOn ) < 0 ) {
              
              sorted_keys.push( key );
              sorted.push( dependency );
              if ( unsorted.length === 0 ) {
                  // Done
                  break;
              }
          } else {
              unsorted.push( dependency ); // Defer sorting for a later pass.
          }
      }
  
      if ( unsorted.length > 0 ) {
          throw "Dependency map contains a circular reference.";
      }
  
      return sorted;
  }