Error in LINQ OrderBy and FindAll methods when using Danish culture (da-DK). - by MortenK

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 771650 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 11/19/2012 2:05:25 PM
Access Restriction Public


When using FindAll and OrderBy LINQ statements on a generic list<string> using Danish culture, errors in the expected output occurs. OrderBy sorts wrongfully (i.e. Not alphabetical), and FindAll.StartsWith doesn't actually find all strings that start with the specified string.

Both problems can be resolved by passing StringComparer.InvariantCultureIgnoreCase to the FindAll / OrderBy methods.
Sign in to post a comment.
Posted by MortenK on 2/21/2013 at 11:15 AM
Hi Immo,

Thanks for the reply. As I mentioned in one of my other comments, I am now aware the sorting mechanism works like that, so OrderBy and FindAll are indeed fine. The real problem, faulty sorting, is still there though. It is not as first assumed in the OrderBy / FindAll methods: It is a problem in the culture configuration instead.

The culture considers double aa to be the same as the character å. However that is wrong, the double aa was removed from the language all the way back in 1948.

I understand that there might be differing opinions on this, and in any case it is certainly not an issue for the .NET framework team, but rather the culture team (if such exists).

Posted by Microsoft on 2/21/2013 at 7:40 AM
Thank you for your feedback. This issue is actually by-design.

This is not an issue with OrderBy or FindAll -- it is how the danish string comparsions work.

"a" is a char
"aa" is also a char but a different one which is why you get the strange looking behavior.

has some more information about some of this issue.

Immo Landwerth
.NET Framework team
Posted by MortenK on 12/21/2012 at 1:29 PM
After researching it, I understand that the reason for the problem is that the Danish culture sorting mechanism treats aa as the danish letter å, which is one of the last letters in the alphabet. Therefore "aab" will appear after "b".

However this is highly unintuitive since the aa spelling of the letter Å was removed from the Danish language in 1948: (origin section).

While this error is not an error in LINQ's sorting mechanism as first assumed, it is still an error, but in the culture configuration instead, and should really be fixed as the end-result is a wrongful sort order.
Posted by Microsoft on 11/22/2012 at 12:33 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Sorry for the first time not reproduced your issue.
Posted by MortenK on 11/20/2012 at 1:58 AM
That's pretty lazy guys, it's 3 lines of code you have to execute and check the output of. I already got the problem fixed by using the workaround, so this bug submission is just for your info.

I made the video: Here I start the BugDemo project in VS, run it, and show that that the output is wrong, by inspecting the objects after hitting a breakpoint.
Posted by Microsoft on 11/19/2012 at 10:58 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting a video. Please submit this information to us within 3 business days. We look forward to hearing from you with this information.
Posted by Microsoft on 11/19/2012 at 2:52 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(