# C1.DataEngine.DataList.Sort

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_DataEngine_DataList_Sort_" data-uid="C1.DataEngine.DataList.Sort*">Sort Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_DataEngine_DataList_Sort_" data-uid="C1.DataEngine.DataList.Sort*"></a>
<h4 id="C1_DataEngine_DataList_Sort_C1_DataEngine_IDataList_System_String_System_Boolean_" data-uid="C1.DataEngine.DataList.Sort(C1.DataEngine.IDataList,System.String,System.Boolean)">Sort(IDataList, string, bool)</h4>
<div class="markdown level1 summary"><p>Sorts a list based on a property name and sort 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 void Sort(IDataList list, string name, bool ascending = true)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Sub Sort(list As IDataList, name As String, Optional ascending As Boolean = True)</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.DataEngine/C1.DataEngine.IDataList.html">IDataList</a></td>
      <td><span class="parametername">list</span></td>
      <td><p>A list of items that implements the <a class="xref" href="../C1.DataEngine/C1.DataEngine.IDataList.html">IDataList</a> interface.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">name</span></td>
      <td><p>The name of the property to sort by.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">ascending</span></td>
      <td><p>A value that indicates whether the sort order is ascending.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_DataEngine_DataList_Sort_C1_DataEngine_IDataList_System_String_System_Boolean__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method can be called multiple times on the same list to specify secondary sort criteria. However, the <code class="paramref">ascending</code> parameter must be the same for each call.</p>
<p>Call this method to set sort criteria <b>before</b> calling <a class="xref" href="C1.DataEngine.ClassFactory.CreateFromDataList.html#C1_DataEngine_ClassFactory_CreateFromDataList_C1_DataEngine_IDataList_System_String_">CreateFromDataList(IDataList, string)</a></p>
</div>
</div>
