Comparer.Ordinal

Comparer

A case-sensitive ordinal comparer function.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Comparer.Ordinal as function

Return Value

functionA comparer function that performs case-sensitive ordinal (byte-level) comparisons.

Remarks

Comparer.Ordinal is a built-in comparer function that performs case-sensitive, byte-level comparisons. It does not account for linguistic or cultural sorting rules — uppercase letters sort before lowercase letters (e.g., "B" comes before "a" in ordinal order).

Use Comparer.Ordinal as an argument to functions like List.Sort, List.Distinct, Table.Distinct, and Table.Sort when you need strict case-sensitive behavior.

Examples

Example 1: Case-sensitive sort of employee names

let
    Names = Table.Column(Employees, "FullName"),
    Sorted = List.Sort(Names, Comparer.Ordinal)
in
    #table({"FullName"}, List.Transform(Sorted, each {_}))
Result
FullName
1BOB JONES
2Charlie Brown
3Eve Martinez
4alice smith
5diana PRINCE
6frank lee

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks