Fetch child pages and sort them as per publish date and time
I have a scenario wherein I've to fetch all the child pages of a parent page (the path will be fetched from dialog) and then sort them as per most recent published date, and when date is time the same should be sorted as per published time...and ultimately just fetch the first 4 elements/pages after sorting.
I've developed a sling model where I'm getting the parent path and then trying to iterate and get the child pages and then store them in an arrayList. I will need some help with the sorting and then ultimately getting the first 4 pages. If someone could help me with the sling model (it'll be great you can provide me with the code snippet).
Attached is the piece of code that I've written.
dynamicArticles denotes the path of the parent page
childrenList is the ArrayList.

@arunpatidar @heenamadan @ksh_ingole7 @santoshsai @b_sravan @sachin_arora_ @pulkit_jain_ @milind_bachani
Thanks!