Issue with the Sorting pages having numbers in name and title | Community
Skip to main content
Level 2
Jun 30, 2017 4:37 AM UTC
Solved

Issue with the Sorting pages having numbers in name and title

Hello,

  I am this specific requirement where pages are created as 1, 3,5,2,1A,4,2B...10,11,12 etc. I am having difficulty while fetch the pages and it comes up as 1,10,11,1A,12,2.... and that is not desired. I can not use listChildren method as it would give me the pages in the order they are created. I tried using query but if I say order by title/nodename then I get into the same issue as query treats the numbers as string.

My desired results are like 1,1A,2,2B,3,4,5...10,11

Any suggestions on how I can do the sorting effectively? Thanks in advance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
smacdonald2008
smacdonald2008Accepted solution
Level 10
Jun 30, 2017 2:49 PM UTC

Have you tried to create a custom Java method in a service that would have a custom sorting algorithm:

algorithm - sorting integers in order lowest to highest java - Stack Overflow 

2 replies

VeenaVikraman
New Participant
Jun 30, 2017 5:38 PM UTC

I agree with scott. The best workaround is to write a custom algorithm to fetch all the pages , get the titles and sort it in the way you want

Translate
smacdonald2008
smacdonald2008Accepted solution
Level 10
Jun 30, 2017 2:49 PM UTC

Have you tried to create a custom Java method in a service that would have a custom sorting algorithm:

algorithm - sorting integers in order lowest to highest java - Stack Overflow 

Translate