sort a list ignoring capitals and german umlauts

hoebbel
Crownpeak employee
Crownpeak employee
3 5 2,015

Normally you can sort database entries within the function contentSelect. But you have to keep in mind, that the result is coming directly from the database. So if the database sorts case sensitive and the umlauts are sorted at the end of the list, you can either reconfigure the database or, if this is not wanted, you can sort the list afterwards.

Example:

<CMS_HEADER>

<CMS_FUNCTION name="contentSelect" resultname="list">
    <CMS_PARAM  name="schema" value="Testschema" />
    <QUERY entityType="SortMe">
        <ORDERCRITERIA attribute="text" descending="0" />
    </QUERY>
</CMS_FUNCTION>
</CMS_HEADER>

<h1>database sorted</h1>
$CMS_FOR(element,list)$
$CMS_VALUE(element.text)$<br>
$CMS_END_FOR$
<h1>manual sorted</h1>
$CMS_FOR(element,list.copy.sort(x -> x.text.toLowerCase().replaceAll("ö","oe").replaceAll("ä","ae")))$
$CMS_VALUE(element.text)$<br>
$CMS_END_FOR$

Output:

<h1>database sorted</h1>
Aachen<br>
Ende<br>
Zukunft<br>
anfang<br>
Ärger<br>
Österreich<br>
ähnlich<br>

<h1>manual sorted</h1>
Aachen<br>
ähnlich<br>
Ärger<br>
anfang<br>
Ende<br>
Österreich<br>
Zukunft<br>

Tested with FS4.2R2

5 Comments
Version history
Last update:
‎07-08-2010 02:23 AM
Updated by: