• Basics
  • Abyss
  • Web APIs
  • C# & Razor
  • .net API
  • JS & TS API

    Show / Hide Table of Contents

    Class ValueSort

    Sort Entity by values in specified Attributes / Properties

    The ValueSort DataSource is part of the Standard EAV Data Sources. It will reorder items passing through A-Z or Z-A based on a value of each item.

    How to use with the VisualQuery

    When using the VisualQuery you can just drag it into your query. This is what it usually looks like:

    The above example shows the same items being sorted in two different ways and delivered to the target.

    Example Using Multi-Sort

    You can also sort multiple fields, so "first sort by xyz, then by xyz" and use different sort-orders.:

    Example Using URL Parameters

    ...and of course you can also use url parameters to specify field-names or sort order:

    Sorting Direction

    For sorting direction you can use either words or numbers

    • asc/desc
    • 1/0

    Programming With The ValueSort DataSource

    We recommend to use the VisualQuery where possible, as it's easier to understand and is identical for C# and JavaScript. It's also better because it separates data-retrieval from visualization.

    // A source which can filter by Content-Type (EntityType)
    var allAuthors = CreateSource<EntityTypeFilter>();
    allAuthors.TypeName = "Author";
    
    // Sort by FullName
    var sortedAuthors = CreateSource<ValueSort>(allAuthors);
    sortedAuthors.Attributes = "FullName";
    

    Read also

    • DataSource / DataStream
    • List of all EAV Data Sources
    • Query / VisualQuery

    Demo App and further links

    You should find some examples in this demo App

    • Demo App with examples for most DataSources

    History

    1. Introduced in EAV 3.x, 2sxc ?

    API Documentation

    Inheritance
    System.Object
    ToSic.Lib.Services.ServiceBase
    ToSic.Lib.Services.ServiceBase<ToSic.Eav.DataSource.DataSourceBase.MyServices>
    DataSourceBase
    ValueSort
    Implements
    IDataSource
    IAppIdentity
    IZoneIdentity
    IAppIdentityLight
    ICacheKey
    ICacheExpiring
    ITimestamped
    IHasLog
    IDataSourceLinkable
    Inherited Members
    DataSourceBase.AppId
    DataSourceBase.ZoneId
    DataSourceBase.Guid
    DataSourceBase.Error
    DataSourceBase.CacheTimestamp
    DataSourceBase.CacheChanged(Int64)
    DataSourceBase.Configuration
    DataSourceBase.Link
    DataSourceBase.In
    DataSourceBase.TryGetIn(String)
    DataSourceBase.TryGetOut(String)
    DataSourceBase.Out
    DataSourceBase.Item[String]
    DataSourceBase.GetStream(String, String, Boolean, Boolean)
    DataSourceBase.List
    DataSourceBase.Attach(IDataSource)
    DataSourceBase.Attach(String, IDataSource, String)
    DataSourceBase.Attach(String, IDataStream)
    DataSourceBase.ProvideOut(Func<IEnumerable<IEntity>>, String)
    DataSourceBase.ProvideOut(Func<IImmutableList<IEntity>>, String)
    Namespace: ToSic.Eav.DataSources
    Assembly: ToSic.Eav.DataSources.dll
    Syntax
    [PublicApi_Stable_ForUseInYourCode]
    [VisualQuery(NiceName = "Value Sort", UiHint = "Sort items by a property", Icon = "sort", Type = DataSourceType.Sort, NameId = "ToSic.Eav.DataSources.ValueSort, ToSic.Eav.DataSources", DynamicOut = false, In = new string[]{"Default*"}, ConfigurationType = "|Config ToSic.Eav.DataSources.ValueSort", HelpLink = "https://r.2sxc.org/DsValueSort")]
    public sealed class ValueSort : DataSourceBase, IDataSource, IAppIdentity, IZoneIdentity, IAppIdentityLight, ICacheInfo, ICacheKey, ICacheExpiring, ITimestamped, ICanPurgeListCache, IHasLog, IDataTarget, IAppIdentitySync, IDataSourceLinkable
    Remarks

    Had a major, breaking update in v15. Consult the guide to upgrade your custom data sources.

    Properties

    | Improve this Doc View Source

    Attributes

    The attribute whose value will be sorted by.

    Declaration
    [Configuration]
    public string Attributes { get; set; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    Directions

    The sorting direction like 'asc' or 'desc', can also be 0, 1

    Declaration
    [Configuration]
    public string Directions { get; set; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    Languages

    Language to filter for. At the moment it is not used, or it is trying to find "any"

    Declaration
    [Configuration(Fallback = "default")]
    public string Languages { get; set; }
    Property Value
    Type Description
    System.String

    Implements

    IDataSource
    IAppIdentity
    IZoneIdentity
    IAppIdentityLight
    ICacheKey
    ICacheExpiring
    ITimestamped
    IHasLog
    IDataSourceLinkable
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX