# C1.DataCollection.IDataCollectionEx.SortAsync

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_DataCollection_IDataCollectionEx_SortAsync_" data-uid="C1.DataCollection.IDataCollectionEx.SortAsync*">SortAsync Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_DataCollection_IDataCollectionEx_SortAsync_" data-uid="C1.DataCollection.IDataCollectionEx.SortAsync*"></a>
<h4 id="C1_DataCollection_IDataCollectionEx_SortAsync__1_C1_DataCollection_IDataCollection___0__System_String_C1_DataCollection_SortDirection_" data-uid="C1.DataCollection.IDataCollectionEx.SortAsync``1(C1.DataCollection.IDataCollection{``0},System.String,C1.DataCollection.SortDirection)">SortAsync&lt;T&gt;(IDataCollection&lt;T&gt;, string, SortDirection)</h4>
<div class="markdown level1 summary"><p>Sorts the data collection according to the specified sort parameters.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static Task SortAsync&lt;T&gt;(this IDataCollection&lt;T&gt; dataCollection, string sortPath, SortDirection sortDirection = SortDirection.Ascending) where T : class?</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function SortAsync(Of T As Class)(dataCollection As IDataCollection(Of T), sortPath As String, Optional sortDirection As SortDirection = SortDirection.Ascending) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.DataCollection.IDataCollection-1.html">IDataCollection</a>&lt;T&gt;</td>
      <td><span class="parametername">dataCollection</span></td>
      <td><p>The data collection.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">sortPath</span></td>
      <td><p>The path of the data item to which the sort description will be applied.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.DataCollection.SortDirection.html">SortDirection</a></td>
      <td><span class="parametername">sortDirection</span></td>
      <td><p>The direction of the sort operation.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td></td>
    </tr>
  </tbody>
</table>


<a id="C1_DataCollection_IDataCollectionEx_SortAsync_" data-uid="C1.DataCollection.IDataCollectionEx.SortAsync*"></a>
<h4 id="C1_DataCollection_IDataCollectionEx_SortAsync__1_C1_DataCollection_IDataCollection___0__System_Linq_Expressions_Expression_System_Func___0_System_Object___C1_DataCollection_SortDirection_" data-uid="C1.DataCollection.IDataCollectionEx.SortAsync``1(C1.DataCollection.IDataCollection{``0},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},C1.DataCollection.SortDirection)">SortAsync&lt;T&gt;(IDataCollection&lt;T&gt;, Expression&lt;Func&lt;T, object&gt;&gt;, SortDirection)</h4>
<div class="markdown level1 summary"><p>Sorts the data collection according to the specified sort path and direction.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static Task SortAsync&lt;T&gt;(this IDataCollection&lt;T&gt; dataCollection, Expression&lt;Func&lt;T, object&gt;&gt; sortPath, SortDirection sortDirection = SortDirection.Ascending) where T : class?</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function SortAsync(Of T As Class)(dataCollection As IDataCollection(Of T), sortPath As Expression(Of Func(Of T, Object)), Optional sortDirection As SortDirection = SortDirection.Ascending) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.DataCollection.IDataCollection-1.html">IDataCollection</a>&lt;T&gt;</td>
      <td><span class="parametername">dataCollection</span></td>
      <td><p>The data collection.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.linq.expressions.expression-1">Expression</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-2">Func</a>&lt;T, <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a>&gt;&gt;</td>
      <td><span class="parametername">sortPath</span></td>
      <td><p>The filter path.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.DataCollection.SortDirection.html">SortDirection</a></td>
      <td><span class="parametername">sortDirection</span></td>
      <td><p>The sort direction.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td></td>
    </tr>
  </tbody>
</table>


<a id="C1_DataCollection_IDataCollectionEx_SortAsync_" data-uid="C1.DataCollection.IDataCollectionEx.SortAsync*"></a>
<h4 id="C1_DataCollection_IDataCollectionEx_SortAsync__1_C1_DataCollection_IDataCollection___0__C1_DataCollection_SortDescription___" data-uid="C1.DataCollection.IDataCollectionEx.SortAsync``1(C1.DataCollection.IDataCollection{``0},C1.DataCollection.SortDescription[])">SortAsync&lt;T&gt;(IDataCollection&lt;T&gt;, params SortDescription[])</h4>
<div class="markdown level1 summary"><p>Sorts the data collection according to the specified sort descriptions.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static Task SortAsync&lt;T&gt;(this IDataCollection&lt;T&gt; dataCollection, params SortDescription[] sortDescriptions) where T : class?</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function SortAsync(Of T As Class)(dataCollection As IDataCollection(Of T), ParamArray sortDescriptions As SortDescription()) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.DataCollection.IDataCollection-1.html">IDataCollection</a>&lt;T&gt;</td>
      <td><span class="parametername">dataCollection</span></td>
      <td><p>The data collection.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.DataCollection.SortDescription.html">SortDescription</a>[]</td>
      <td><span class="parametername">sortDescriptions</span></td>
      <td><p>The sort descriptions that determine how the data will be sort.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td></td>
    </tr>
  </tbody>
</table>


<a id="C1_DataCollection_IDataCollectionEx_SortAsync_" data-uid="C1.DataCollection.IDataCollectionEx.SortAsync*"></a>
<h4 id="C1_DataCollection_IDataCollectionEx_SortAsync__1_C1_DataCollection_IDataCollection___0__C1_DataCollection_SortDescription___System_Threading_CancellationToken_" data-uid="C1.DataCollection.IDataCollectionEx.SortAsync``1(C1.DataCollection.IDataCollection{``0},C1.DataCollection.SortDescription[],System.Threading.CancellationToken)">SortAsync&lt;T&gt;(IDataCollection&lt;T&gt;, SortDescription[], CancellationToken)</h4>
<div class="markdown level1 summary"><p>Sorts the data collection according to the specified sort descriptions.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static Task SortAsync&lt;T&gt;(this IDataCollection&lt;T&gt; dataCollection, SortDescription[] sortDescriptions, CancellationToken cancellationToken = default) where T : class?</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function SortAsync(Of T As Class)(dataCollection As IDataCollection(Of T), sortDescriptions As SortDescription(), Optional cancellationToken As CancellationToken = Nothing) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.DataCollection.IDataCollection-1.html">IDataCollection</a>&lt;T&gt;</td>
      <td><span class="parametername">dataCollection</span></td>
      <td><p>The data collection.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.DataCollection.SortDescription.html">SortDescription</a>[]</td>
      <td><span class="parametername">sortDescriptions</span></td>
      <td><p>The sort descriptions that determine how the data will be sort.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken">CancellationToken</a></td>
      <td><span class="parametername">cancellationToken</span></td>
      <td><p>The cancellation token.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td></td>
    </tr>
  </tbody>
</table>
</div>
