code: func Sort(releasePackages []*Package) ([]*Package, error) {
  	sortedPackages := []*Package{}
  
  	incomingEdges, outgoingEdges := getEdgeMaps(releasePackages)
  	noIncomingEdgesSet := []*Package{}
  
  	for pkg, edgeList := range incomingEdges {
  		if len(edgeList) == 0 {
  			noIncomingEdgesSet = append(noIncomingEdgesSet, pkg)
  		}
  	}
  	for len(noIncomingEdgesSet) > 0 {
  		elem := noIncomingEdgesSet[0]
  		noIncomingEdgesSet = noIncomingEdgesSet[1:]
  
  		sortedPackages = append([]*Package{elem}, sortedPackages...)
  
  		for _, pkg := range outgoingEdges[elem] {
  			incomingEdges[pkg] = removeFromList(incomingEdges[pkg], elem)
  			if len(incomingEdges[pkg]) == 0 {
  				noIncomingEdgesSet = append(noIncomingEdgesSet, pkg)
  			}
  		}
  	}
  	for _, edges := range incomingEdges {
  		if len(edges) > 0 {
  			return nil, errors.New("Circular dependency detected while sorting packages")
  		}
  	}
  	return sortedPackages, nil
  }
docs: // Topologically sorts an array of packages