public List <Post> GetNextPosts(ref int page, out int pageCount, string sortBy, int postsPerPage, string author) { var posts = SelectSorting(sortBy)(GetPosts(author)); // selects sorting delegate based on sort type and calls the method referenced by the delegate int postCount = posts.Count(); //pagination page = (postCount / postsPerPage) == 0 ? 0 : page; int remainingPosts = postCount - page * postsPerPage; pageCount = postCount % postsPerPage > 0 ? ((postCount / postsPerPage) + 1) : (postCount / postsPerPage); int skip = page * postsPerPage; int take = remainingPosts < postsPerPage ? remainingPosts : postsPerPage; return(posts.Skip(skip).Take(take).ToList()); }
public static void Select <T>(IList <T> nums, int low, int high, Func <T, T, bool> max) { SelectSorting.Sort(nums, low, high, max); }
public static void Select <T>(IList <T> nums, Func <T, T, bool> max) { SelectSorting.Sort(nums, max); }
public static void Sort <T>(IList <T> nums, Func <T, T, bool> max) { SelectSorting.Sort(nums, 0, nums.Count - 1, max); }