<?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: Bubble Sorts</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2009/01/02/bubble-sorts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2009/01/02/bubble-sorts/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Wed, 08 Feb 2012 23:58:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/02/bubble-sorts/#comment-36955</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Wed, 07 Jan 2009 20:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1931#comment-36955</guid>
		<description>&lt;p&gt;My post with a quicksort procedure hasn&#039;t shown up, so I&#039;ll try again. Note: using FORTRAN-like comparison operators to eliminate the hassles with angle brackets.&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; qsort( _&lt;br&gt;
&#160;v &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;, _&lt;br&gt;
&#160;lft &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, _&lt;br&gt;
&#160;rgt &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, _&lt;br&gt;
&#160;&lt;span class=&quot;kw1&quot;&gt;Optional&lt;/span&gt; asc &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Boolean&lt;/span&gt; = &lt;span class=&quot;kw1&quot;&gt;True&lt;/span&gt; _&lt;br&gt;
)&lt;br&gt;
&lt;span class=&quot;co1&quot;&gt;&#039;--------------------------------&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;co1&quot;&gt;&#039;assumes simple 1D arrays&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;co1&quot;&gt;&#039;defaults to ascending sort&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;co1&quot;&gt;&#039;--------------------------------&lt;br&gt;
&lt;/span&gt; &#160;&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; j &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, pvt &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, t &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; lft .GE. rgt &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Exit&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&#160; j = lft + Int((rgt - lft + 1) * Rnd)&lt;br&gt;
&#160; t = v(lft)&lt;br&gt;
&#160; v(lft) = v(j)&lt;br&gt;
&#160; v(j) = t&lt;br&gt;
&lt;br&gt;
&#160; pvt = lft&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; j = lft + 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; rgt&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; IIf(asc, v(j) .LT. v(lft), v(j) .GT. v(lft)) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; pvt = pvt + 1&lt;br&gt;
&#160; &#160; &#160; t = v(pvt)&lt;br&gt;
&#160; &#160; &#160; v(pvt) = v(j)&lt;br&gt;
&#160; &#160; &#160; v(j) = t&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; j&lt;br&gt;
&lt;br&gt;
&#160; t = v(lft)&lt;br&gt;
&#160; v(lft) = v(pvt)&lt;br&gt;
&#160; v(pvt) = t&lt;br&gt;
&#160; &lt;br&gt;
&#160; qsort v, lft, pvt - 1, asc&lt;br&gt;
&#160; qsort v, pvt + 1, rgt, asc&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>My post with a quicksort procedure hasn&#8217;t shown up, so I&#8217;ll try again. Note: using FORTRAN-like comparison operators to eliminate the hassles with angle brackets.</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Sub</span> qsort( _<br />
&nbsp;v <span class="kw1">As</span> <span class="kw1">Variant</span>, _<br />
&nbsp;lft <span class="kw1">As</span> <span class="kw1">Long</span>, _<br />
&nbsp;rgt <span class="kw1">As</span> <span class="kw1">Long</span>, _<br />
&nbsp;<span class="kw1">Optional</span> asc <span class="kw1">As</span> <span class="kw1">Boolean</span> = <span class="kw1">True</span> _<br />
)<br />
<span class="co1">&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
</span><span class="co1">&#8216;assumes simple 1D arrays<br />
</span><span class="co1">&#8216;defaults to ascending sort<br />
</span><span class="co1">&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
</span> &nbsp;<span class="kw1">Dim</span> j <span class="kw1">As</span> <span class="kw1">Long</span>, pvt <span class="kw1">As</span> <span class="kw1">Long</span>, t <span class="kw1">As</span> <span class="kw1">Variant</span></p>
<p>&nbsp; <span class="kw1">If</span> lft .GE. rgt <span class="kw1">Then</span> <span class="kw1">Exit</span> <span class="kw1">Sub</span></p>
<p>&nbsp; j = lft + Int((rgt &#8211; lft + 1) * Rnd)<br />
&nbsp; t = v(lft)<br />
&nbsp; v(lft) = v(j)<br />
&nbsp; v(j) = t</p>
<p>&nbsp; pvt = lft</p>
<p>&nbsp; <span class="kw1">For</span> j = lft + 1 <span class="kw1">To</span> rgt<br />
&nbsp; &nbsp; <span class="kw1">If</span> IIf(asc, v(j) .LT. v(lft), v(j) .GT. v(lft)) <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; pvt = pvt + 1<br />
&nbsp; &nbsp; &nbsp; t = v(pvt)<br />
&nbsp; &nbsp; &nbsp; v(pvt) = v(j)<br />
&nbsp; &nbsp; &nbsp; v(j) = t<br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
&nbsp; <span class="kw1">Next</span> j</p>
<p>&nbsp; t = v(lft)<br />
&nbsp; v(lft) = v(pvt)<br />
&nbsp; v(pvt) = t<br />
&nbsp; <br />
&nbsp; qsort v, lft, pvt &#8211; 1, asc<br />
&nbsp; qsort v, pvt + 1, rgt, asc<br />
<span class="kw1">End</span> <span class="kw1">Sub</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/02/bubble-sorts/#comment-36806</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Sat, 03 Jan 2009 05:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1931#comment-36806</guid>
		<description>&lt;p&gt;OK...ok...I&#039;ll redo #29 with a quicksort and post it in a few days.  Here&#039;s a reference on all kinds of sorts (quick/heap/shaker etc) with code:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://69.20.37.124/showthread.php?p=403676&quot; rel=&quot;nofollow&quot;&gt;http://69.20.37.124/showthread.php?p=403676&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;From the folks over at Xtreme Visual Basic.&lt;/p&gt;
&lt;p&gt;You guys sound like my old CS profs...;-)&lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>OK&#8230;ok&#8230;I&#8217;ll redo #29 with a quicksort and post it in a few days.  Here&#8217;s a reference on all kinds of sorts (quick/heap/shaker etc) with code:</p>
<p><a href="http://69.20.37.124/showthread.php?p=403676" rel="nofollow">http://69.20.37.124/showthread.php?p=403676</a></p>
<p>From the folks over at Xtreme Visual Basic.</p>
<p>You guys sound like my old CS profs&#8230;;-)</p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dbb</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/02/bubble-sorts/#comment-36799</link>
		<dc:creator>dbb</dc:creator>
		<pubDate>Sat, 03 Jan 2009 01:17:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1931#comment-36799</guid>
		<description>&lt;p&gt;Michael, quicksort code is also short, but it runs up to 200x as fast as bubblesort. &lt;/p&gt;
&lt;p&gt;I sorted 10,000 random (long) numbers in 0.03 seconds vs 6 seconds with bubblesort.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Michael, quicksort code is also short, but it runs up to 200x as fast as bubblesort. </p>
<p>I sorted 10,000 random (long) numbers in 0.03 seconds vs 6 seconds with bubblesort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Woodhouse</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/02/bubble-sorts/#comment-36798</link>
		<dc:creator>Mike Woodhouse</dc:creator>
		<pubDate>Sat, 03 Jan 2009 01:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1931#comment-36798</guid>
		<description>&lt;p&gt;Bubble sort. Ugh. As wikipedia &lt;a href=&quot;http://en.wikipedia.org/wiki/Sorting_algorithm&quot; rel=&quot;nofollow&quot;&gt;says&lt;/a&gt;, &quot;While simple, this algorithm is highly inefficient and is rarely used except in education&quot;&lt;/p&gt;
&lt;p&gt;I&#039;ll readily agree that it works, but surely we should make some room to attempt to produce a little elegance? Any of the algortihms that is O(n log n) for time and O(1) for memory (I get nervous about the stack for highly recursive sorts) would do. Heapsort isn&#039;t hard to implement in VBA (I&#039;m sure I have one somewhere).&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Bubble sort. Ugh. As wikipedia <a href="http://en.wikipedia.org/wiki/Sorting_algorithm" rel="nofollow">says</a>, &#8220;While simple, this algorithm is highly inefficient and is rarely used except in education&#8221;</p>
<p>I&#8217;ll readily agree that it works, but surely we should make some room to attempt to produce a little elegance? Any of the algortihms that is O(n log n) for time and O(1) for memory (I get nervous about the stack for highly recursive sorts) would do. Heapsort isn&#8217;t hard to implement in VBA (I&#8217;m sure I have one somewhere).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

