Search code examples
.netazure-cosmosdbazure-cosmosdb-sqlapi

Which .NET StringComparison is equivalent to the ordering in Cosmos DB?


  1. Is there any official documentation specifying precisely how strings are compared/ordered in Cosmos DB?

  2. Am I correct to assume that StringComparer.Ordinal in .NET is 100% equivalent to string comparison in Cosmos DB?


Solution

    1. As of today, the answer seems to be no.
    2. As @Martin Smith has mentioned in the comments, the client source code uses string.CompareOrdinal() to order results from cross-partition queries in memory, which is a very strong argument for the hypothesis that the database backend uses precisely the same ordering. But since the database backend is not open source and there is no authoritative documentation on this issue, this remains an (highly) educated guess.