Expand my Community achievements bar.

SOLVED

Issue with the Sorting pages having numbers in name and title

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Level 10

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 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

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 

Avatar

Community Advisor

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