Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay 7.2 - How to user OrderByComparator?
Hi,
I am getting my Journal Articles with the API:
But this is returning a list of Articles from the oldest to the newest. How should I use the OrderByComparator to order the Journal Articles from the newest to the oldest?
I am getting my Journal Articles with the API:
JournalArticleLocalServiceUtil.getArticles(groupId, 0, 16);
But this is returning a list of Articles from the oldest to the newest. How should I use the OrderByComparator to order the Journal Articles from the newest to the oldest?
Hi,
You can refer and use below journal api
https://docs.liferay.com/ce/apps/web-experience/latest/javadocs/com/liferay/journal/service/JournalArticleLocalServiceUtil.html#getArticles-long-int-int-com.liferay.portal.kernel.util.OrderByComparator-
You can refer this for OrderByComparator http://liferaytutorial.blogspot.com/2013/12/order-by-comparator.html
You can refer and use below journal api
https://docs.liferay.com/ce/apps/web-experience/latest/javadocs/com/liferay/journal/service/JournalArticleLocalServiceUtil.html#getArticles-long-int-int-com.liferay.portal.kernel.util.OrderByComparator-
You can refer this for OrderByComparator http://liferaytutorial.blogspot.com/2013/12/order-by-comparator.html
Thanks Mohammed!
I ended up with the following:
I ended up with the following:
OrderByComparator<journalarticle> comparator = OrderByComparatorFactoryUtil.create("JournalArticle", "displayDate", "desc");</journalarticle>
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™