[#BloombergLP-bdlb-TopologicalSortUtil-sort-07]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/TopologicalSortUtil.adoc[TopologicalSortUtil]::sort
:relfileprefix: ../../../
:mrdocs:

`sort` overloads

== Synopses

Declared in `&lt;bdlb&lowbar;topologicalsortutil&period;h&gt;`

Sort nodes into topological order given edge relations&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class NODE&lowbar;TYPE&gt;
static
bool
xref:BloombergLP/bdlb/TopologicalSortUtil/sort-04.adoc[sort](
    xref:bsl/vector-00d.adoc[bsl::vector&lt;NODE&lowbar;TYPE&gt;]* result,
    xref:bsl/vector-00d.adoc[bsl::vector&lt;NODE&lowbar;TYPE&gt;]* unsorted,
    xref:bsl/vector-00d.adoc[bsl::vector&lt;bsl::pair&lt;NODE&lowbar;TYPE, NODE&lowbar;TYPE&gt;&gt;] const& relations);
----

[.small]#xref:BloombergLP/bdlb/TopologicalSortUtil/sort-04.adoc[_» more&period;&period;&period;_]#

Sort input edges into topological order via output iterators&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class INPUT&lowbar;ITER,
    class OUTPUT&lowbar;ITER,
    class UNSORTED&lowbar;OUTPUT&lowbar;ITER&gt;
static
bool
xref:BloombergLP/bdlb/TopologicalSortUtil/sort-03.adoc[sort](
    INPUT&lowbar;ITER relationsBegin,
    INPUT&lowbar;ITER relationsEnd,
    OUTPUT&lowbar;ITER resultOutIter,
    UNSORTED&lowbar;OUTPUT&lowbar;ITER unsortedOutIter);
----

[.small]#xref:BloombergLP/bdlb/TopologicalSortUtil/sort-03.adoc[_» more&period;&period;&period;_]#

== Return Value

`true` if the sort succeeds, and `false` if a cycle is found

== Parameters

[cols="1,4"]
|===
| Name| Description
| *result*
| destination for the ordered nodes
| *unsorted*
| destination for nodes left unsorted on failure
| *relations*
| directed edges (U, V) where U precedes V
| *relationsBegin*
| beginning of the input edge range
| *relationsEnd*
| end of the input edge range
| *resultOutIter*
| output iterator for the ordered nodes
| *unsortedOutIter*
| output iterator for unsorted nodes on failure
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
