Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

How do I alphabetically order a list of pages and ignore accents?

Avatar

Level 2

Hello,

I have a list of pages that I am querying using xpath and ordering by jcr:title.

How do I ignore accented characters?

For example if I have a page with jcr:title = Études, it will show up at the bottom of the list instead of near the top.

 

Thank you.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

In SQL2 query (also known as JCR-SQL2), you can use the COLLATE function to ignore accented characters when ordering by jcr:title. The COLLATE function allows you to specify a collation to control the sorting behavior.

Here's an example of an SQL2 query that ignores accented characters when ordering by jcr:title:

SELECT * FROM [nt:base] AS node
WHERE ISDESCENDANTNODE('/path/to/your/pages')
ORDER BY COLLATE(node.[jcr:title], 'ICU_Locale=fr,strength=primary')

In this example, ICU_Locale=fr specifies that the collation should follow French language rules for sorting, and strength=primary specifies that only primary differences (such as accented characters) should be considered significant for ordering.

By using the COLLATE function with the appropriate collation settings, you can ensure that accented characters are ignored when ordering your pages by jcr:title. This will result in a more accurate sorting order that takes into account language-specific rules.

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

In SQL2 query (also known as JCR-SQL2), you can use the COLLATE function to ignore accented characters when ordering by jcr:title. The COLLATE function allows you to specify a collation to control the sorting behavior.

Here's an example of an SQL2 query that ignores accented characters when ordering by jcr:title:

SELECT * FROM [nt:base] AS node
WHERE ISDESCENDANTNODE('/path/to/your/pages')
ORDER BY COLLATE(node.[jcr:title], 'ICU_Locale=fr,strength=primary')

In this example, ICU_Locale=fr specifies that the collation should follow French language rules for sorting, and strength=primary specifies that only primary differences (such as accented characters) should be considered significant for ordering.

By using the COLLATE function with the appropriate collation settings, you can ensure that accented characters are ignored when ordering your pages by jcr:title. This will result in a more accurate sorting order that takes into account language-specific rules.