<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Блог Костика &#187; English</title>
	<atom:link href="http://blog.piterpen.net/category/english/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.piterpen.net</link>
	<description>Какой-то я странный: то могучий, то не могучий!</description>
	<lastBuildDate>Tue, 27 Jul 2010 09:46:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Kazakhstan businessman bought Sealand?</title>
		<link>http://blog.piterpen.net/2007/01/16/12/</link>
		<comments>http://blog.piterpen.net/2007/01/16/12/#comments</comments>
		<pubDate>Tue, 16 Jan 2007 06:54:15 +0000</pubDate>
		<dc:creator>kostik</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[lytdybr]]></category>

		<guid isPermaLink="false">http://blog.piterpen.net/2007/01/16/kazakstan-businessman-bought-sealand/</guid>
		<description><![CDATA[Kazakhstan&#8217;s site akipress.org informed, that Daniyar Ashimbaev (Данияр Ашимбаев) bought a SeaLand few days ago and is going to be a new SeaLand &#8220;king&#8221;. Akipress published a large interview (in Russian) with this person. He does not mention any reasons &#8230; <a href="http://blog.piterpen.net/2007/01/16/12/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Kazakhstan&#8217;s site <a href="http://kz.akipress.org">akipress.org</a> informed, that Daniyar Ashimbaev (Данияр Ашимбаев) bought a <a href="http://www.sealandgov.org/">SeaLand</a> few days ago and is going to be a new SeaLand &#8220;king&#8221;. Akipress published a<a href="http://kz.akipress.org/news/4354"> large interview</a> (in Russian) with this person. He does not mention any reasons of this deal and does not say exactly how he will use the SeaLand, but promise, for example, to change SeaLand Dollar to SeaLand Tenge (Kazakhstan&#8217;s currency). I can not find any confirmations of this deal at other news sources, and I hope it is a fake.</p>
<p><strong>update: </strong>It was a fake of course. Never trust local news sites 8-).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.piterpen.net/2007/01/16/12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yet another faster JavaScript sorting</title>
		<link>http://blog.piterpen.net/2007/01/08/7/</link>
		<comments>http://blog.piterpen.net/2007/01/08/7/#comments</comments>
		<pubDate>Mon, 08 Jan 2007 19:12:43 +0000</pubDate>
		<dc:creator>kostik</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[работа]]></category>

		<guid isPermaLink="false">http://blog.piterpen.net/2007/01/08/yet-another-faster-javascript-sorting/</guid>
		<description><![CDATA[It&#160;is&#160;no&#160;secret that the demand on&#160;applications with &#8220;AJAX&#8221; in&#160;the name is&#160;continually increasing. Nolens volens one has to&#160;do&#160;some things with unadapted to&#160;them tools: an&#160;illustration in&#160;point is&#160;Internet Explorer&#160;&#8212; a&#160;program which is&#160;unadapted to&#160;execution of&#160;the code that would be&#160;standardized and had a&#160;common sense. Recently I&#160;had &#8230; <a href="http://blog.piterpen.net/2007/01/08/7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&nbsp;is&nbsp;no&nbsp;secret that the demand on&nbsp;applications with &ldquo;AJAX&rdquo; in&nbsp;the name is&nbsp;continually increasing. Nolens volens one has to&nbsp;do&nbsp;some things with unadapted to&nbsp;them tools: an&nbsp;illustration in&nbsp;point is&nbsp;Internet Explorer&nbsp;&mdash; a&nbsp;program which is&nbsp;unadapted to&nbsp;execution of&nbsp;the code that would be&nbsp;standardized and had a&nbsp;common sense. Recently I&nbsp;had to&nbsp;deal with one of&nbsp;its problems. I&nbsp;had to&nbsp;sort out an&nbsp;array of&nbsp;objects by&nbsp;the given field. IE&nbsp;did it&nbsp;100&nbsp;times slower than FireFox! Solution allows sorting out six times faster than Internet Explorer. A&nbsp;link to&nbsp;the library implementing this method follows. <span id="more-7"></span></p>
<h3>Problem</h3>
<p>With trivial code</p>
<p>// Array а&nbsp;contains 15000&nbsp;elements<br />
a.sort(function(a,&nbsp;b){return b.item&nbsp;&mdash; a.item;})</p>
<p>IE&nbsp;needs 40(!) seconds to&nbsp;think (15000&nbsp;was taken as&nbsp;a&nbsp;test, a&nbsp;real array is&nbsp;certainly less). (FireFox does the same in&nbsp;422ms, approximately 100&nbsp;times faster!) The realization of&nbsp;the sorting process on&nbsp;the server side would require changing of&nbsp;a&nbsp;large part of&nbsp;the code because the user selects a&nbsp;field and a&nbsp;method of&nbsp;sorting; this was a&nbsp;problem.</p>
<h3>Solution</h3>
<p>After short googling I&nbsp;found an&nbsp;<a href="http://www.lindsay.id.au/blog/?p=6">excellent article by&nbsp;Russel Lindsay: &ldquo;Faster Javascript sorting&rdquo;</a>. He&nbsp;uses a&nbsp;simple trick: to&nbsp;rewrite the method toString() for addressing to&nbsp;the object&#8217;s property directly, convert numbers ([1, 2,&nbsp;10]&nbsp;into strings ['01','02','10']) and use sort() without parameters for increasing sorting speed. Below the results of&nbsp;the test (with my&nbsp;implementation of&nbsp;this idea):</p>
<pre>Internet Explorer41516ms – sort(function(a, b){return b.item - a.item;})

7031ms - sort() for the array where numbers were converted into string

7047ms – sort() and reverse() for the array where numbers were converted into stringFireFox

438ms – sort(function(a, b){return b.item - a.item;})

891ms - sort() for the array where numbers were converted into string

954ms – sort() and reverse() for the array where numbers were converted into string</pre>
<p>Thus the trick of&nbsp;adding numbers with zeros to&nbsp;strings gives a&nbsp;six times quicker sorting in&nbsp;Internet Explorer and twice slower sorting in&nbsp;FF&nbsp;which allows using the code in&nbsp;both browsers.</p>
<p>Russel Lindsay uses the fixed size mask and the array ([1, 2,&nbsp;10]&nbsp;turns not into [01, 02,&nbsp;10]&nbsp;but into ['00000000001',' 00000000002',' 00000000010']). This is&nbsp;awful for many reasons and memory used is&nbsp;one of&nbsp;them. So&nbsp;I&nbsp;wrote a&nbsp;small library based on&nbsp;his code. It&nbsp;adds to&nbsp;Array() following methods: Array.sortIntAsc(property) and Array.sortIntDesc(property) for sorting array by&nbsp;integer property, Array.sortAsc(property), and Array.sortDesc(property) for sorting by&nbsp;string property.</p>
<h3>Example</h3>
<p>[js] var team = [<br />
{name:&rsquo;Bill&rsquo;, age:25},<br />
{name:&rsquo;John&rsquo;, age:21},<br />
{name:&rsquo;Ann&rsquo;, age:20}<br />
];</p>
<p>alert([team[0].name,team[1].name,team[2].name]);<br />
// Bill, John, Ann</p>
<p>team.sortIntAsc(&rsquo;age&rsquo;);<br />
alert([team[0].name,team[1].name,team[2].name]);<br />
// Ann, John, Bill</p>
<p>team.sortAsc(&rsquo;name&rsquo;);<br />
alert([team[0].name,team[1].name,team[2].name]);<br />
// Ann, Bill, John</p>
<p>[/js]</p>
<h3>My&nbsp;2&nbsp;cents</h3>
<p>This method is&nbsp;in&nbsp;my&nbsp;humble opinion a&nbsp;good solution of&nbsp;this particular problem (thank you, <a href="http://www.lindsay.id.au/blog/?p=6">Russel</a>!). Also it&nbsp;is&nbsp;a&nbsp;good illustration: the best way to&nbsp;do&nbsp;something with data in&nbsp;the Internet Explorer is&nbsp;not to&nbsp;do&nbsp;anything. I&nbsp;mean to&nbsp;organize the data processing flow in&nbsp;such a&nbsp;way as&nbsp;to&nbsp;leave the data processing (including any sorting) on&nbsp;the server side. Otherwise when IE&nbsp;will deal with trivial tasks terrible you will have to&nbsp;spend a&nbsp;lot of&nbsp;time to&nbsp;find a&nbsp;strange detour.</p>
<p><a href="http://blog.piterpen.net/wp-content/uploads/2007/01/arraysort.zip"> download library (zip)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.piterpen.net/2007/01/08/7/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
