<?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: Sorting Vectors</title>
	<atom:link href="http://jacksondunstan.com/articles/270/feed" rel="self" type="application/rss+xml" />
	<link>http://jacksondunstan.com/articles/270</link>
	<description>Mastering AS3</description>
	<lastBuildDate>Tue, 07 Feb 2012 09:30:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Vector Sortierindex - Flashforum</title>
		<link>http://jacksondunstan.com/articles/270/comment-page-1#comment-3961</link>
		<dc:creator>Vector Sortierindex - Flashforum</dc:creator>
		<pubDate>Thu, 17 Feb 2011 01:41:08 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=270#comment-3961</guid>
		<description>[...] hilft evtl.: Sorting Vectors JacksonDunstan.com  Ob Vectors immer so sinnvoll ist, gerade bzgl. Sortierung ist inbegriffen.   __________________ [...]</description>
		<content:encoded><![CDATA[<p>[...] hilft evtl.: Sorting Vectors JacksonDunstan.com  Ob Vectors immer so sinnvoll ist, gerade bzgl. Sortierung ist inbegriffen.   __________________ [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/270/comment-page-1#comment-753</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Thu, 29 Jul 2010 17:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=270#comment-753</guid>
		<description>This post was about a year old and needed some updating to my new performance article format, so I did that and took the opportunity to integrate your suggestion (also the suggestion of &lt;a href=&quot;#comment-561&quot; rel=&quot;nofollow&quot;&gt;jloa&lt;/a&gt; above). While your approach does create a large &lt;tt&gt;Array&lt;/tt&gt; that the garbage collector may have to collect, it&#039;s possible to have this pre-allocated and re-used so as to avoid the penalty. Under those conditions&#8212;where we don&#039;t have to count the GC time&#8212;your approach is about 2x faster than &lt;tt&gt;Vector.sort()&lt;/tt&gt;, the next-fastest &lt;tt&gt;Vector&lt;/tt&gt; sorting approach.

Thanks for the tip!</description>
		<content:encoded><![CDATA[<p>This post was about a year old and needed some updating to my new performance article format, so I did that and took the opportunity to integrate your suggestion (also the suggestion of <a href="#comment-561" rel="nofollow">jloa</a> above). While your approach does create a large <tt>Array</tt> that the garbage collector may have to collect, it&#8217;s possible to have this pre-allocated and re-used so as to avoid the penalty. Under those conditions&mdash;where we don&#8217;t have to count the GC time&mdash;your approach is about 2x faster than <tt>Vector.sort()</tt>, the next-fastest <tt>Vector</tt> sorting approach.</p>
<p>Thanks for the tip!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bwhiting</title>
		<link>http://jacksondunstan.com/articles/270/comment-page-1#comment-751</link>
		<dc:creator>bwhiting</dc:creator>
		<pubDate>Thu, 29 Jul 2010 13:26:33 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=270#comment-751</guid>
		<description>have you tried just using an array for the sort then using that to build your vector?

http://blog.bwhiting.co.uk/?p=34</description>
		<content:encoded><![CDATA[<p>have you tried just using an array for the sort then using that to build your vector?</p>
<p><a href="http://blog.bwhiting.co.uk/?p=34" rel="nofollow">http://blog.bwhiting.co.uk/?p=34</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/270/comment-page-1#comment-640</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Thu, 13 May 2010 19:01:18 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=270#comment-640</guid>
		<description>It&#039;s not really fair to compare the generalized &lt;tt&gt;indexOf&lt;/tt&gt; that works with all arrays to a function that works only with sorted arrays. For example, it&#039;d be just as unfair if I made a search function that only worked with arrays that only have two elements:

&lt;pre lang=&quot;actionscript3&quot;&gt;
function search(a:Array, val:*): int
{
	return a[0] == val ? 0 : (a[1] == val ? 1 : -1);
}
&lt;/pre&gt;

I&#039;m sure that&#039;s much faster than the binary search or &lt;tt&gt;indexOf&lt;/tt&gt;... as long as you meet the special conditions. But that doesn&#039;t mean I&#039;ve &quot;beaten&quot; the native code.</description>
		<content:encoded><![CDATA[<p>It&#8217;s not really fair to compare the generalized <tt>indexOf</tt> that works with all arrays to a function that works only with sorted arrays. For example, it&#8217;d be just as unfair if I made a search function that only worked with arrays that only have two elements:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">search</span><span style="color: #000000;">&#40;</span>a<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000066; font-weight: bold;">,</span> val<span style="color: #000066; font-weight: bold;">:*</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">return</span> a<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span> == val <span style="color: #000066; font-weight: bold;">?</span> <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000;">&#40;</span>a<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span> == val <span style="color: #000066; font-weight: bold;">?</span> <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>I&#8217;m sure that&#8217;s much faster than the binary search or <tt>indexOf</tt>&#8230; as long as you meet the special conditions. But that doesn&#8217;t mean I&#8217;ve &#8220;beaten&#8221; the native code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eco_bach</title>
		<link>http://jacksondunstan.com/articles/270/comment-page-1#comment-639</link>
		<dc:creator>eco_bach</dc:creator>
		<pubDate>Thu, 13 May 2010 14:32:25 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=270#comment-639</guid>
		<description>Jack
when you say &#039;You simply can’t beat native code with ActionScript, &#039; I disagree. I  the case of searching a large array with indexOf() vs a binary search, I believe the latter is always faster(as long as the array is sorted first).
http://stackoverflow.com/questions/1987163/binary-search-from-java-to-actionscript</description>
		<content:encoded><![CDATA[<p>Jack<br />
when you say &#8216;You simply can’t beat native code with ActionScript, &#8216; I disagree. I  the case of searching a large array with indexOf() vs a binary search, I believe the latter is always faster(as long as the array is sorted first).<br />
<a href="http://stackoverflow.com/questions/1987163/binary-search-from-java-to-actionscript" rel="nofollow">http://stackoverflow.com/questions/1987163/binary-search-from-java-to-actionscript</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/270/comment-page-1#comment-615</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Wed, 07 Apr 2010 21:35:31 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=270#comment-615</guid>
		<description>In practice the &lt;tt&gt;Vector&lt;/tt&gt; would probably not be local to the function but instead stored long-term as a field of an object. Even so, &lt;a href=&quot;http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/system/System.html#gc()&quot; rel=&quot;nofollow&quot;&gt;System.gc()&lt;/a&gt; only works in the debug version of Flash Player, which most people don&#039;t have installed. As for caring about performance, it&#039;s true that most Flash apps won&#039;t care much about 1000 elements of a &lt;tt&gt;Vector&lt;/tt&gt;, but larger, more resource-intensive ones can&#039;t afford to ignore that kind of extra memory usage in many places before the app is too heavy for some users.</description>
		<content:encoded><![CDATA[<p>In practice the <tt>Vector</tt> would probably not be local to the function but instead stored long-term as a field of an object. Even so, <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/system/System.html#gc()" rel="nofollow">System.gc()</a> only works in the debug version of Flash Player, which most people don&#8217;t have installed. As for caring about performance, it&#8217;s true that most Flash apps won&#8217;t care much about 1000 elements of a <tt>Vector</tt>, but larger, more resource-intensive ones can&#8217;t afford to ignore that kind of extra memory usage in many places before the app is too heavy for some users.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jloa</title>
		<link>http://jacksondunstan.com/articles/270/comment-page-1#comment-614</link>
		<dc:creator>jloa</dc:creator>
		<pubDate>Wed, 07 Apr 2010 17:29:41 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=270#comment-614</guid>
		<description>Well, all you have to do is to call the System.gc after the sorting operation, the gc will clean up the memory as the array is local-based.
Speaking of performance, nope, sincerely, i haven&#039;t tested the performance, but still if you r making a web site and have a vector of 1000 elements eg will u care about the performance? :)
Yeap, i will test it and post the results.</description>
		<content:encoded><![CDATA[<p>Well, all you have to do is to call the System.gc after the sorting operation, the gc will clean up the memory as the array is local-based.<br />
Speaking of performance, nope, sincerely, i haven&#8217;t tested the performance, but still if you r making a web site and have a vector of 1000 elements eg will u care about the performance? :)<br />
Yeap, i will test it and post the results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/270/comment-page-1#comment-562</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Wed, 10 Mar 2010 02:25:43 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=270#comment-562</guid>
		<description>For CPU and memory performance. Converting to a temporary Array requires twice the memory and creates garbage to be collected right away. I can&#039;t imagine it&#039;s a very fast solution either, even disregarding the allocation and GC time. Have you performance tested it?

By the way, you could improve the performance of your implementation by using the &lt;tt&gt;new Array(size)&lt;/tt&gt; constructor since you know how much many elements you need before doing the copy.</description>
		<content:encoded><![CDATA[<p>For CPU and memory performance. Converting to a temporary Array requires twice the memory and creates garbage to be collected right away. I can&#8217;t imagine it&#8217;s a very fast solution either, even disregarding the allocation and GC time. Have you performance tested it?</p>
<p>By the way, you could improve the performance of your implementation by using the <tt>new Array(size)</tt> constructor since you know how much many elements you need before doing the copy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jloa</title>
		<link>http://jacksondunstan.com/articles/270/comment-page-1#comment-561</link>
		<dc:creator>jloa</dc:creator>
		<pubDate>Tue, 09 Mar 2010 17:30:23 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=270#comment-561</guid>
		<description>omg, guys, why do u complicate yr life with such code?! O_O.

To do a Vector.sortOn u need only 5 code lines.
http://chargedweb.com/labs/2010/02/20/vector-sorton/</description>
		<content:encoded><![CDATA[<p>omg, guys, why do u complicate yr life with such code?! O_O.</p>
<p>To do a Vector.sortOn u need only 5 code lines.<br />
<a href="http://chargedweb.com/labs/2010/02/20/vector-sorton/" rel="nofollow">http://chargedweb.com/labs/2010/02/20/vector-sorton/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin</title>
		<link>http://jacksondunstan.com/articles/270/comment-page-1#comment-339</link>
		<dc:creator>Valentin</dc:creator>
		<pubDate>Sat, 31 Oct 2009 09:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=270#comment-339</guid>
		<description>Array sort is indeed much slower than manual sort functions implementations on numbers.</description>
		<content:encoded><![CDATA[<p>Array sort is indeed much slower than manual sort functions implementations on numbers.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

