简体   繁体   中英

Sorting out a list of items in ascending date

My page has a list of events I'm sorting into order by the following line of code:

 results = CurrentPage.Children
   .Where("eventDate >= minDate AND eventDate < maxDate", month)
   .OrderBy("eventDate desc")
   .Skip(currentPage * itemsPerPage)
   .Take(itemsPerPage);

This returns all my items in descending order by date. So right now it goes from August 2015 , July 2015 and so on. What I need is for it show the reverse.

I've tried looking to see if there is an ascending call in the OrderBy() method but I can't find anything. Can someone please help me?

Using desc means to descend. You should use ASC like below and it should work.

results = CurrentPage.Children.Where("eventDate >= minDate AND eventDate < maxDate", month)
                           .OrderBy("eventDate asc")
                           .Skip(currentPage * itemsPerPage)
                           .Take(itemsPerPage);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM