Comparer.OrdinalIgnoreCase
Compares two values exactly, except that capitals and small letters count as the same.
Group: Splitters, combiners, replacers and comparers. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Comparer.OrdinalIgnoreCase(x as any, y as any) as number
| Parameter | Type | Description |
|---|---|---|
x | any | The first value. |
y | any | The second value. |
Returns
number. -1 when x comes first, 0 when they are equal apart from case, 1 when y comes first.
Remarks
- Letters beyond English ones too: Æ, Ø and Å match æ, ø and å, Ł matches ł. Each character is compared as its capital, so ß does not match SS.
- Pass it where a function takes a comparer:
List.Sort,List.Distinct,List.Containsand others.
Examples
Sorting without regard to case
List.Sort({"banana", "Apple", "Cherry"}, Comparer.OrdinalIgnoreCase)
{"Apple", "banana", "Cherry"}
One of each shop, whatever its capitals
List.Distinct({"Oslo", "OSLO", "Bergen"}, Comparer.OrdinalIgnoreCase)
{"Oslo", "Bergen"}
Norwegian letters
Comparer.OrdinalIgnoreCase("ÆRØ", "ærø")
0
Related functions
Comparer.Ordinal, Comparer.FromCulture, Comparer.Equals, List.Distinct.