<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx</link><description>There is a great deal of confusion surrounding the meaning of these two different things in the .NET Framework, and when to use each. If you have suffered, are suffering, or think may suffer in the future from such a confusion, then read on! (Otherwise,</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#344323</link><pubDate>Thu, 30 Dec 2004 16:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:344323</guid><dc:creator>Panos Theofanopoulos</dc:creator><description>for 1000000 comparisons&lt;br&gt;&lt;br&gt;Ordinal : 47 mseconds&lt;br&gt;&lt;a title="InvariantCulture" href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemglobalizationcultureinfoclassinvariantculturetopic.asp" target="_blank"&gt;InvariantCulture&lt;/a&gt; : 299 mseconds&lt;br&gt;&lt;br&gt;OrdinalIgnoreCase : 188 mseconds&lt;br&gt;InvariantCultureIgnoreCase : 245 mseconds&lt;br&gt;&lt;br&gt;This post brought to you by &amp;quot;Ώ&amp;quot; (U+038F, GREEK CAPITAL LETTER OMEGA WITH TONOS) which beats Ω, ω and ώ in a binary sort :-)</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#344331</link><pubDate>Thu, 30 Dec 2004 16:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:344331</guid><dc:creator>Michael Kaplan</dc:creator><description>Heh heh heh -- see what I mean?&lt;br&gt;&lt;br&gt;You do have to be careful with the perf testing in an actual app situation to use representative strings. The reason is that in both cases (ordinal *and* invariant) the code will exit as soon as it finds the winner. &lt;br&gt;&lt;br&gt;In order (therefore) to get the most effective test you have to craft the strings to match the kind of comparisons you will see in your app.&lt;br&gt;&lt;br&gt;I'll get more into how it works internally in a future post. :-)</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#344339</link><pubDate>Thu, 30 Dec 2004 16:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:344339</guid><dc:creator>Michael Kaplan</dc:creator><description>BTW -- Panos, in answer to your suggestion to the MSDN Feedback Center:&lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=2682c87e-5c46-4697-bbed-6f0de0047a7d"&gt;http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=2682c87e-5c46-4697-bbed-6f0de0047a7d&lt;/a&gt; &lt;br&gt;&lt;br&gt;True benchmarks for these methods under load, with indications of where the true slowdowns are, is the way to proceed here. IMHO, all perf. work has to be done that way....&lt;br&gt;&lt;br&gt;</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#346625</link><pubDate>Wed, 05 Jan 2005 01:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:346625</guid><dc:creator>Norman Diamond</dc:creator><description>&amp;gt; Note that these string comparisons still had&lt;br&gt;&amp;gt; much linguistic value -- half of the locales&lt;br&gt;&amp;gt; in Windows use that default table, so an&lt;br&gt;&amp;gt; invariant sort would not only avoid varying,&lt;br&gt;&amp;gt; it would also look right to a lot of the&lt;br&gt;&amp;gt; world.&lt;br&gt;&lt;br&gt;Isn't linguistic value counterproductive for the intended value of the invariant locale?  Didn't you say in an earlier posting that people shouldn't use the invariant locale for human-oriented operations?  Surely the way to discourage people from using the invariant locale for sorting is to make the results appear wrong for every known culture in the world?</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#346630</link><pubDate>Wed, 05 Jan 2005 01:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:346630</guid><dc:creator>Michael Kaplan</dc:creator><description>&amp;gt; Isn't linguistic value counterproductive for the intended value of the invariant locale? &lt;br&gt;&lt;br&gt;No, not at all. I have explained the exact purpose of the invariant locale, and that is NOT it.&lt;br&gt;&lt;br&gt;&amp;gt; you say in an earlier posting that people shouldn't use the invariant locale for human-oriented operations?&lt;br&gt;&lt;br&gt;No, I said that about ORDINAL comparisons.&lt;br&gt;&lt;br&gt;&amp;gt; Surely the way to discourage people from using the invariant locale for sorting is to make the results appear wrong for every known culture in the world?&lt;br&gt;&lt;br&gt;Well, no one is trying to discourage invariant sorting. So I have to reject the premise here.</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#346746</link><pubDate>Wed, 05 Jan 2005 06:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:346746</guid><dc:creator>Norman Diamond</dc:creator><description>In page&lt;br&gt;&lt;a target="_new" href="http://weblogs.asp.net/michkap/archive/2004/12/08/278170.aspx"&gt;http://weblogs.asp.net/michkap/archive/2004/12/08/278170.aspx&lt;/a&gt;&lt;br&gt;you said:&lt;br&gt;&amp;gt; The invariant locale is pretty weird. Lets&lt;br&gt;&amp;gt; take a look at its interesting&lt;br&gt;&amp;gt; chracteristics.&lt;br&gt;[...]&lt;br&gt;&amp;gt; Its data was chosen to dissuade people from&lt;br&gt;&amp;gt; trying to use it as a locale. And that is&lt;br&gt;&amp;gt; putting it charitably.&lt;br&gt;&lt;br&gt;That did not say ordinal comparisons, that said the invariant locale.  Please look at your own posting an un-reject the premise here.&lt;br&gt;&lt;br&gt;Now, to help dissaude people from trying to use the invariant locale as a locale, would it not have been beneficial to avoid giving it linguistic values?  Would it not have been better if sort results were wrong for every human language?</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#346768</link><pubDate>Wed, 05 Jan 2005 08:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:346768</guid><dc:creator>Michael Kaplan</dc:creator><description>It was intended to be used for sorting, we want it used for sorting. This was the REASON it was added. It will not change, and we would not want it to change even if we had the option.&lt;br&gt;&lt;br&gt;When I spoke of trying to make it less appealing as a locale, I am referring to EVERYTHING ELSE beyond collation.&lt;br&gt;&lt;br&gt;I hope these words are plain enough.</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#347334</link><pubDate>Thu, 06 Jan 2005 00:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:347334</guid><dc:creator>Norman Diamond</dc:creator><description>Yes it is clearer this time.&lt;br&gt;&lt;br&gt;Though I still think it would be better if the invariant locale's sort ordering differed from every human language so that no one would be tempted to use it for human-oriented sorting.  For internal ordering of databases and finding hash keys and running scripts in a uniform manner it would still be fine (which I thought its intended purpose was).</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#347347</link><pubDate>Thu, 06 Jan 2005 01:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:347347</guid><dc:creator>Michael Kaplan</dc:creator><description>Norman, I understand you think this.&lt;br&gt;&lt;br&gt;Do you understand that we do not and that we intend it to be used and we have no ingtention of telling people not to use it? &lt;br&gt;&lt;br&gt;It is basically the same as saying &amp;quot;use English&amp;quot; or whatever -- the default table. Thats what its job is, and it does that well. &lt;br&gt;&lt;br&gt;Its not fair to change the requirement based on what you think it ought to do, and thus make it nor perform well. :-(</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#347483</link><pubDate>Thu, 06 Jan 2005 07:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:347483</guid><dc:creator>Norman Diamond</dc:creator><description>Then you should call it the English locale and not the invariant locale.  (Unless you really meant the en-US locale.)  Attaching a non-provincial label for the purpose of appearing non-provincial while still making the factual behavior every bit as provincial as your other thread said you were trying to avoid, just yields another bit of pretense with continued provincialism.  Also since facts of the invariant locale look like en-US, it will no longer be surprsing when US developers overuse it and use it for undesirable purposes.</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#347525</link><pubDate>Thu, 06 Jan 2005 09:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:347525</guid><dc:creator>Michael Kaplan</dc:creator><description>Norman, you are wrong once again. Over half othe languages there are also in the defualt table. I can say use Hebrew. Or German. Or any number of locales instead. Thinking it is provincial to take the word &amp;quot;English&amp;quot; out of it is plain silly.&lt;br&gt;&lt;br&gt;No if you look at the REST of the data, it looks nothing like English. Or Arabic. Or German. Or Hebrew. Or any of the other 50 locales that use the table. So go ahead and try to claim it is a provincial attempt to push a particular culture if you must -- but those who are reading will have long seen who gets it.&lt;br&gt;&lt;br&gt;What we do here with invariant has a valid and explainable purpose.</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#348083</link><pubDate>Fri, 07 Jan 2005 01:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:348083</guid><dc:creator>Michael Kaplan</dc:creator><description>Further comments that find to be inappopriate the intended purpose and use of the invariant locale's collation behavior (to use the DEFAULT collation table used by half of the locales in Windows) will not be accepted.&lt;br&gt;&lt;br&gt;Those with dissenting opinions on the topic are invited to create their own blogs or web pages where they can explain the amount of evil-ness (evility?) in Microsoft's implementaion choices.</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#349029</link><pubDate>Sat, 08 Jan 2005 03:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:349029</guid><dc:creator>Norman Diamond</dc:creator><description>1/6/2005 1:08 AM Michael Kaplan&lt;br&gt;&lt;br&gt;&amp;gt; Thinking it is provincial to take the&lt;br&gt;&amp;gt; word &amp;quot;English&amp;quot; out of it is plain silly. &lt;br&gt;&lt;br&gt;Of course it is.  That's why I didn't use the word provincial that way.  I used the word provincial in the way you used it in page&lt;br&gt;&lt;a target="_new" href="http://weblogs.asp.net/michkap/archive/2004/12/08/278170.aspx"&gt;http://weblogs.asp.net/michkap/archive/2004/12/08/278170.aspx&lt;/a&gt;&lt;br&gt;and I agree with the way you used it there.</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#349031</link><pubDate>Sat, 08 Jan 2005 03:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:349031</guid><dc:creator>Michael Kaplan</dc:creator><description>Yes, but did you read the whole article?&lt;br&gt;&lt;br&gt;&amp;quot;...since the only real goal anyway was to &amp;quot;use the default table&amp;quot; for sorting...&amp;quot;&lt;br&gt;&lt;br&gt;Our point is therefore entirely clear here for all to see (and read).&lt;br&gt;&lt;br&gt;Microsoft Windows and the .NET Framework work as designed in regard to the INVARIANT locale/culture. The only bug we have now is the inappropriate expectations of one Norman Diamond. :-)</description></item><item><title>Invariant and Ordinal Redux</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#407824</link><pubDate>Wed, 13 Apr 2005 14:58:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:407824</guid><dc:creator>Sorting It All Out</dc:creator><description>I have talked about LOCALE_INVARIANT / CultureInfo.InvariantCulture before, in Comparison confusion:...</description></item><item><title>Intelligent unmanaged string comparison</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#412080</link><pubDate>Tue, 26 Apr 2005 13:32:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:412080</guid><dc:creator>Sorting It All Out</dc:creator><description>If you look at the documentation for CompareString&amp;amp;amp;nbsp;(but not LCMapString, though it probably ought...</description></item><item><title>Why do NTFS and Explorer disagree on filename sorting?</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#430198</link><pubDate>Fri, 17 Jun 2005 18:17:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:430198</guid><dc:creator>The Old New Thing</dc:creator><description>Because they have different goals.</description></item><item><title>Invariant vs. Ordinal, the third</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#605851</link><pubDate>Wed, 24 May 2006 14:41:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:605851</guid><dc:creator>Sorting It All Out</dc:creator><description>Mike Sheldon is one of the smartest guys I know.&lt;br&gt;You may have seen him on Channel 9 talking about Windows...</description></item><item><title>It has not always been so invariant</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#727609</link><pubDate>Mon, 28 Aug 2006 03:51:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:727609</guid><dc:creator>Sorting It All Out</dc:creator><description>&lt;BR&gt;The other day, Bill asked the following question: &lt;BR&gt;&lt;BR&gt;Anyway, I have the following...</description></item><item><title>When methods use collation to 'disturb the peace' we charge them with being 'out of sorts'</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#2071501</link><pubDate>Tue, 10 Apr 2007 15:05:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2071501</guid><dc:creator>Sorting It All Out</dc:creator><description>&lt;P&gt;You know how I talk about best practices here sometimes? And the worst ways to misuse various globalization/internationalization&lt;/P&gt;</description></item><item><title>The nature of OrdinalIgnoreCase vs. intuitive expectations</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#2273364</link><pubDate>Wed, 25 Apr 2007 18:45:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2273364</guid><dc:creator>Sorting It All Out</dc:creator><description>&lt;p&gt;A while back Patrick asked me: Hi Michael, Please forward if you’re not the right person to ask the question…&lt;/p&gt;
</description></item><item><title>The exception that proves the rule that was the exception that proves another rule (aka On the variability of the Invariant)</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#2569987</link><pubDate>Sat, 12 May 2007 14:57:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2569987</guid><dc:creator>Sorting It All Out</dc:creator><description>&lt;p&gt;It was over two years ago that Shawn talked about how Culture data shouldn't be considered stable (except&lt;/p&gt;
</description></item><item><title>re: Comparison confusion: INVARIANT vs. ORDINAL</title><link>http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx#8920180</link><pubDate>Tue, 02 Sep 2008 19:00:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8920180</guid><dc:creator>Phil Hackett</dc:creator><description>&lt;p&gt;Thanks Michael - that article was -really- useful. &amp;nbsp;It's a shame the official Microsoft help/documentation doesn't explain this, really, as it's such an obvious question that people are bound to ask.&lt;/p&gt;</description></item></channel></rss>