Sort a list of users

Oct 28, 2015 at 12:48 AM
I have a list of DNN users and would like to sort them by name

@foreach( UserInfo aUser in theUsers)
   {
      stuff
   }
How to I do this?
Oct 28, 2015 at 7:28 PM
The sample app "FAQ with Categories and 6 views" shows an example of sorting.

Check it out here: FAQ with Categories

From the sample:
@functions{
    // Prepare the data - get all categories through the pipeline
    public override void CustomizeData()
    {
        // new features in 6.1 - the App DataSource CreateSource<App> and also the RelationshipFilter
        var qsOfCat = CreateSource<RelationshipFilter>(App.Data["QandA"]);
        qsOfCat.Relationship = "Categories";
        qsOfCat.Filter = Content.Category.Count > 0 ? Content.Category[0].Name : "";
        var sorted = CreateSource<ValueSort>(qsOfCat);
        sorted.Attributes = "EntityTitle";
        Data.In.Add("QandA", sorted["Default"]);
    }
}
And then...
<ol>
    @foreach (var q in AsDynamic(Data["QandA"]))
    {
        <li class="sc-element faq-set" data-tags="@String.Join(",", ((List<DynamicEntity>)q.Categories).Select(a => AsDynamic(a).EntityId))">
            @q.Toolbar
            <a class="faq-question" style="cursor: pointer">
                @q.Question
            </a>
            <div class="faq-answer" style="display: none">@Html.Raw(q.Answer)</div>
        </li>
    }
</ol>