How do I get LINQ to order according to culture?

You can't do this with a query expression, but you can do it with explicit dot notation:

var result = fruits.OrderBy(f => f, StringComparer.CurrentCulture);

That should do it, assuming the thread's current culture is correct. Alternatively:

CultureInfo culture = new CultureInfo("sv-SE");
var result = fruits.OrderBy(f => f, StringComparer.Create(culture, false));

I've tried your use case and it did provide valid results without a need to provide culture-specific comparer (both in .NET 3.5 and .NET 4.0):

    Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("sv-SE");
    var fruits = new[] { "banan", "äpple", "apelsin", "druva" };
    var result = (from f in fruits orderby f select f).ToList();

    // outputs: apelsin, banan, druva, äpple
    string resultsJoined = string.Join(", ", result);

Tags:

C#

Linq

Sorting