using System.Linq; using Sieve.Sample.Entities; using Sieve.Services; namespace Sieve.Sample.Services { public class SieveCustomSortMethods : ISieveCustomSortMethods { public IQueryable Popularity(IQueryable source, bool useThenBy) => useThenBy ? ((IOrderedQueryable)source).ThenBy(p => p.LikeCount) : source.OrderBy(p => p.LikeCount) .ThenBy(p => p.CommentCount) .ThenBy(p => p.DateCreated); } }