This function compares two alphanumeric strings.
Unlike lexicographic comparison which compares the coding value of each character, this comparison uses a collation which enables two character strings to be compared according to a given language.
It returns 0 if the two strings are the same (the comparison is case sensitive). It returns a value lower than 0 if the first string is strictly lower than the second. It returns a value higher than 0 if the first string is higher than the second.
Parameters
String |
stringVal1 |
Alphanumeric string to compare |
Mandatory |
String |
stringVal2 |
Alphanumeric string to compare |
Mandatory |
Hash |
collatorInfos |
Definition of collation information. This object can have the following attributes:
|
Optional. If this object is not provided, the locale taken for the comparison is that entered for template execution ("strength" and "decomposition" attributes will have a default value which depends on the locale). |
For example
<#assign stringVal1 = "foo" /> <#assign stringVal2 = "bar" /> <#assign compare = hardisCore.localeBasedCompareString(stringVal1, stringVal2) /> <#if compare == 0> ${stringVal1} equals ${stringVal2} <#elseif compare > 0> ${stringVal1} is greater than ${stringVal2} <#else> ${stringVal1} is less than ${stringVal2} </#if>