<?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: Natural Order Numerical Sorting</title>
	<atom:link href="http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/feed/" rel="self" type="application/rss+xml" />
	<link>http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/</link>
	<description>Thoughts, news, code by Sean Murphy</description>
	<lastBuildDate>Tue, 13 Jul 2010 06:36:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Robbie</title>
		<link>http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/comment-page-1/#comment-14</link>
		<dc:creator>Robbie</dc:creator>
		<pubDate>Fri, 18 Jul 2008 11:18:57 +0000</pubDate>
		<guid isPermaLink="false">http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/#comment-14</guid>
		<description>The right maximum level query is:

&quot;SELECT max(level) FROM test&quot;

Where:

1     -&gt; level = 0
1.1   -&gt; level = 1
1.1.1 -&gt; level = 2 

and so on</description>
		<content:encoded><![CDATA[<p>The right maximum level query is:</p>
<p>&#8220;SELECT max(level) FROM test&#8221;</p>
<p>Where:</p>
<p>1     -&gt; level = 0<br />
1.1   -&gt; level = 1<br />
1.1.1 -&gt; level = 2 </p>
<p>and so on</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robbie</title>
		<link>http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/comment-page-1/#comment-13</link>
		<dc:creator>Robbie</dc:creator>
		<pubDate>Fri, 18 Jul 2008 10:37:39 +0000</pubDate>
		<guid isPermaLink="false">http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/#comment-13</guid>
		<description>The previous doesn&#039;t work, sorry.

I tested this, and it is work fine:

$c = ($m + 1); //$m = max of level -&gt; $query = &quot;SELECT max(version) FROM test&quot;

$queryStr = &quot;Round(SUBSTRING_INDEX(version,&#039;.&#039;,1))&quot;;

for ($i = 2; $i &lt; ($c + 1); $i++) {
	$queryStr .= &quot;, Round(RIGHT(SUBSTRING_INDEX(version,&#039;.&#039;,&quot;.$i.&quot;),((LENGTH(SUBSTRING_INDEX(version,&#039;.&#039;,&quot;.$i.&quot;))-1)-LENGTH(SUBSTRING_INDEX(version,&#039;.&#039;,&quot;.($i-1).&quot;)))))&quot;;
}

$query = &quot;SELECT version FROM test ORDER BY $queryStr ASC&quot;;</description>
		<content:encoded><![CDATA[<p>The previous doesn&#8217;t work, sorry.</p>
<p>I tested this, and it is work fine:</p>
<p>$c = ($m + 1); //$m = max of level -&gt; $query = &#8220;SELECT max(version) FROM test&#8221;</p>
<p>$queryStr = &#8220;Round(SUBSTRING_INDEX(version,&#8217;.',1))&#8221;;</p>
<p>for ($i = 2; $i &lt; ($c + 1); $i++) {<br />
	$queryStr .= &#8220;, Round(RIGHT(SUBSTRING_INDEX(version,&#8217;.',&#8221;.$i.&#8221;),((LENGTH(SUBSTRING_INDEX(version,&#8217;.',&#8221;.$i.&#8221;))-1)-LENGTH(SUBSTRING_INDEX(version,&#8217;.',&#8221;.($i-1).&#8221;)))))&#8221;;<br />
}</p>
<p>$query = &#8220;SELECT version FROM test ORDER BY $queryStr ASC&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robbie</title>
		<link>http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/comment-page-1/#comment-12</link>
		<dc:creator>Robbie</dc:creator>
		<pubDate>Fri, 18 Jul 2008 07:33:45 +0000</pubDate>
		<guid isPermaLink="false">http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/#comment-12</guid>
		<description>Try this:

SELECT version FROM test ORDER BY (REPLACE(version , &#039;.&#039;, &#039;&#039;) ASC</description>
		<content:encoded><![CDATA[<p>Try this:</p>
<p>SELECT version FROM test ORDER BY (REPLACE(version , &#8216;.&#8217;, &#8221;) ASC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/comment-page-1/#comment-10</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Thu, 03 Jul 2008 04:27:48 +0000</pubDate>
		<guid isPermaLink="false">http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/#comment-10</guid>
		<description>Thank you.</description>
		<content:encoded><![CDATA[<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Murphy</title>
		<link>http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/comment-page-1/#comment-8</link>
		<dc:creator>Sean Murphy</dc:creator>
		<pubDate>Fri, 27 Jun 2008 22:11:10 +0000</pubDate>
		<guid isPermaLink="false">http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/#comment-8</guid>
		<description>Robert, unfortunately the technique I outlined only works for two decimals. For each decimal you add the ORDER BY clause must get more and more complex.</description>
		<content:encoded><![CDATA[<p>Robert, unfortunately the technique I outlined only works for two decimals. For each decimal you add the ORDER BY clause must get more and more complex.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/comment-page-1/#comment-7</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Fri, 27 Jun 2008 18:58:27 +0000</pubDate>
		<guid isPermaLink="false">http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/#comment-7</guid>
		<description>Its very interesting but it didnt work for me.

&#124; 2.1.0.135 &#124;           2.1 &#124; 
&#124; 2.1.0.134 &#124;           2.1 &#124; 
&#124; 2.1.0.133 &#124;           2.1 &#124; 
&#124; 2.1.0.132 &#124;           2.1 &#124; 
&#124; 2.1.0.131 &#124;           2.1 &#124; 
&#124; 2.1.0.130 &#124;           2.1 &#124; 
&#124; 2.1.0.13  &#124;           2.1 &#124; &lt;&lt;&lt;&lt;&lt;&lt;&lt;
&#124; 2.1.0.129 &#124;           2.1 &#124; 
&#124; 2.1.0.128 &#124;           2.1 &#124; 
&#124; 2.1.0.127 &#124;           2.1 &#124; 
&#124; 2.1.0.126 &#124;           2.1 &#124; 
&#124; 2.1.0.126 &#124;           2.1 &#124; 
&#124; 2.1.0.126 &#124;           2.1 &#124; 
&#124; 2.1.0.126 &#124;           2.1 &#124;</description>
		<content:encoded><![CDATA[<p>Its very interesting but it didnt work for me.</p>
<p>| 2.1.0.135 |           2.1 |<br />
| 2.1.0.134 |           2.1 |<br />
| 2.1.0.133 |           2.1 |<br />
| 2.1.0.132 |           2.1 |<br />
| 2.1.0.131 |           2.1 |<br />
| 2.1.0.130 |           2.1 |<br />
| 2.1.0.13  |           2.1 | &lt;&lt;&lt;&lt;&lt;&lt;&lt;<br />
| 2.1.0.129 |           2.1 |<br />
| 2.1.0.128 |           2.1 |<br />
| 2.1.0.127 |           2.1 |<br />
| 2.1.0.126 |           2.1 |<br />
| 2.1.0.126 |           2.1 |<br />
| 2.1.0.126 |           2.1 |<br />
| 2.1.0.126 |           2.1 |</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Van Aerde</title>
		<link>http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/comment-page-1/#comment-5</link>
		<dc:creator>Ben Van Aerde</dc:creator>
		<pubDate>Thu, 15 May 2008 08:23:24 +0000</pubDate>
		<guid isPermaLink="false">http://iamseanmurphy.com/2007/08/20/natural-order-numerical-sorting/#comment-5</guid>
		<description>Many thanks for this tip!
In addition to the howto: it also works when using other characters than a dot. For example: I used dashes, and it still sorted correctly.</description>
		<content:encoded><![CDATA[<p>Many thanks for this tip!<br />
In addition to the howto: it also works when using other characters than a dot. For example: I used dashes, and it still sorted correctly.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
