<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JavaScript natural order string comparison</title>
	<atom:link href="http://blog.coomanskristof.be/2006/08/01/javascript-natural-order-string-comparison/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.coomanskristof.be/2006/08/01/javascript-natural-order-string-comparison/</link>
	<description>Weblog of Kristof Coomans</description>
	<lastBuildDate>Tue, 05 Oct 2010 12:08:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
	<item>
		<title>By: sasha</title>
		<link>http://blog.coomanskristof.be/2006/08/01/javascript-natural-order-string-comparison/comment-page-1/#comment-11731</link>
		<dc:creator>sasha</dc:creator>
		<pubDate>Thu, 01 Mar 2007 17:51:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coomanskristof.be/2006/08/01/javascript-natural-order-string-comparison/#comment-11731</guid>
		<description>You could add something like this:
        var cm = ca.localeCompare(cb) ;
 	if (cm) return cm ;
Rather then this

  	if (ca  cb) {
             return +1;
         }
To compare strings based on system locale


Additionally if you want case-insensitive comparisson you should not do it in the function itself, but rather send it lower-case arguments  like this

natcompare (arg1.toLowerCase() , arg2.toLowerCase())

or with locale support:

natcompare (arg1.toLocaleLowerCase() , arg2.toLocaleLowerCase())</description>
		<content:encoded><![CDATA[<p>You could add something like this:<br />
        var cm = ca.localeCompare(cb) ;<br />
 	if (cm) return cm ;<br />
Rather then this</p>
<p>  	if (ca  cb) {<br />
             return +1;<br />
         }<br />
To compare strings based on system locale</p>
<p>Additionally if you want case-insensitive comparisson you should not do it in the function itself, but rather send it lower-case arguments  like this</p>
<p>natcompare (arg1.toLowerCase() , arg2.toLowerCase())</p>
<p>or with locale support:</p>
<p>natcompare (arg1.toLocaleLowerCase() , arg2.toLocaleLowerCase())</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Braden</title>
		<link>http://blog.coomanskristof.be/2006/08/01/javascript-natural-order-string-comparison/comment-page-1/#comment-3062</link>
		<dc:creator>Braden</dc:creator>
		<pubDate>Tue, 12 Dec 2006 19:24:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coomanskristof.be/2006/08/01/javascript-natural-order-string-comparison/#comment-3062</guid>
		<description>Thank you. This script is great. I am adding a case-insensitive option for my own use. If you want to add it into the trunk, I just added this block, which may not be the most efficient way:
&lt;code&gt;
    var ia = 0, ib = 0;
    var nza = 0, nzb = 0;
    var ca, cb;
    var result;
    
+    if (i) {
+       a = a.toLowerCase();
+       b = b.toLowerCase();
+    }
+    
    while (true)
    {
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Thank you. This script is great. I am adding a case-insensitive option for my own use. If you want to add it into the trunk, I just added this block, which may not be the most efficient way:<br />
<code><br />
    var ia = 0, ib = 0;<br />
    var nza = 0, nzb = 0;<br />
    var ca, cb;<br />
    var result;</p>
<p>+    if (i) {<br />
+       a = a.toLowerCase();<br />
+       b = b.toLowerCase();<br />
+    }<br />
+<br />
    while (true)<br />
    {<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kristof</title>
		<link>http://blog.coomanskristof.be/2006/08/01/javascript-natural-order-string-comparison/comment-page-1/#comment-1118</link>
		<dc:creator>Kristof</dc:creator>
		<pubDate>Tue, 19 Sep 2006 06:08:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coomanskristof.be/2006/08/01/javascript-natural-order-string-comparison/#comment-1118</guid>
		<description>Hello Ben

I mailed Martin twice but he does not seem to be very responsive :-)

Tried again with another address today, I hope the mail reaches his destination now.</description>
		<content:encoded><![CDATA[<p>Hello Ben</p>
<p>I mailed Martin twice but he does not seem to be very responsive <img src='http://blog.coomanskristof.be/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Tried again with another address today, I hope the mail reaches his destination now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Reser</title>
		<link>http://blog.coomanskristof.be/2006/08/01/javascript-natural-order-string-comparison/comment-page-1/#comment-1116</link>
		<dc:creator>Ben Reser</dc:creator>
		<pubDate>Tue, 19 Sep 2006 02:00:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coomanskristof.be/2006/08/01/javascript-natural-order-string-comparison/#comment-1116</guid>
		<description>You might want to get Martin Pool to update the script on the sourceforge site.  I bumped into the but and debugged and fixed it myself.  I was then looking for where I found it and bumped into your blog and found your already fixed version.  But the one on the sourceforge page is still broken.</description>
		<content:encoded><![CDATA[<p>You might want to get Martin Pool to update the script on the sourceforge site.  I bumped into the but and debugged and fixed it myself.  I was then looking for where I found it and bumped into your blog and found your already fixed version.  But the one on the sourceforge page is still broken.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

