lib/browser/api/menu-utils.js
function sortTopologically (originalOrder, edgesById) {
  const sorted = []
  const marked = new Set()

  const visit = (mark) => {
    if (marked.has(mark)) return
    marked.add(mark)
    const edges = edgesById.get(mark)
    if (edges != null) {
      edges.forEach(visit)
    }
    sorted.push(mark)
  }

  originalOrder.forEach(visit)
  return sorted
}
function sortTopologically (originalOrder, edgesById) {
  const sorted = []
  const marked = new Set()

  const visit = (mark) => {
    if (marked.has(mark)) return
    marked.add(mark)
    const edges = edgesById.get(mark)
    if (edges != null) {
      edges.forEach(visit)
    }
    sorted.push(mark)
  }

  originalOrder.forEach(visit)
  return sorted
}
function sortTopologically ( originalOrder , edgesById ) { const sorted = [ ] const marked = new Set ( ) const visit = ( mark ) => { if ( marked . has ( mark ) ) return marked . add ( mark ) const edges = edgesById . get ( mark ) if ( edges != null ) { edges . forEach ( visit ) } sorted . push ( mark ) } originalOrder . forEach ( visit ) return sorted }
Sort nodes topologically using a depth-first approach. Encountered cycles are broken.
Sort nodes topologically using a depth - first approach . Encountered cycles are broken .