<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Attractive Chaos &#187; software</title>
	<atom:link href="http://attractivechaos.wordpress.com/tag/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://attractivechaos.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 29 Sep 2009 22:22:13 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='attractivechaos.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/3aaf4ad34bfdf87dcbb70d9e3cbd326d?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Attractive Chaos &#187; software</title>
		<link>http://attractivechaos.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://attractivechaos.wordpress.com/osd.xml" title="Attractive Chaos" />
		<item>
		<title>Improved GNU sort (from textutils-1.22)</title>
		<link>http://attractivechaos.wordpress.com/2008/08/22/improved-gnu-sort-from-textutils-122/</link>
		<comments>http://attractivechaos.wordpress.com/2008/08/22/improved-gnu-sort-from-textutils-122/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 22:24:44 +0000</pubDate>
		<dc:creator>attractivechaos</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[myprog]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=157</guid>
		<description><![CDATA[GNU sort is one of my favorite program. It is fast and highly flexible. However, when I try to sort chromosome names, it becomes a pain. In bioinformatics, chromosomes are usually named as chr1, chr2, &#8230;, chr10, chr11, &#8230; chr20, &#8230;, chrX and chrY. It seems to me that there is no way to sort [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=attractivechaos.wordpress.com&blog=4545823&post=157&subd=attractivechaos&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>GNU sort is one of my favorite program. It is fast and highly flexible. However, when I try to sort chromosome names, it becomes a pain. In bioinformatics, chromosomes are usually named as chr1, chr2, &#8230;, chr10, chr11, &#8230; chr20, &#8230;, chrX and chrY. It seems to me that there is no way to sort these names in the above order. Finally, I decide to modify GNU sort. I separate sort source codes from textutils-1.22 because this version is less dependent on other packages.</p>
<p>The string comparison function is:</p>
<pre class="brush: cpp;">static int mixed_numcompare(const char *a, const char *b)
{
  char *pa, *pb;
  pa = (char*)a; pb = (char*)b;
  while (*pa &amp;&amp; *pb) {
    if (isdigit(*pa) &amp;&amp; isdigit(*pb)) {
      long ai, bi;
      ai = strtol(pa, &amp;pa, 10);
      bi = strtol(pb, &amp;pb, 10);
      if (ai != bi) return ai&lt;bi? -1 : ai&gt;bi? 1 : 0;
    } else {
      if (*pa != *pb) break;
      ++pa; ++pb;
    }
  }
  if (*pa == *pb)
  return (pa-a) &lt; (pb-b)? -1 : (pa-a) &gt; (pb-b)? 1 : 0;
  return *pa&lt;*pb? -1 : *pa&gt;*pb? 1 : 0;
}</pre>
<p>It does numerical comparison for digits and string comparison for other characters. With this comparison, chromosome names can be sorted in the desired way. I add a new command line option -N (or -k1,1N) to trigger string-digits mixed comparison.</p>
<p>In addition, I also replace the top-down recursive mergesort with a bottom-up iterative sort, and use heap to accelerate merging. The improved sort is a little faster than the orginal version.</p>
<p>The improved sort can be downloaded <a href="http://www.freewebs.com/attractivechaos/sort-1.22a.tar.bz2">here</a>, distributed under GPL.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/attractivechaos.wordpress.com/157/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/attractivechaos.wordpress.com/157/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/attractivechaos.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/attractivechaos.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/attractivechaos.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/attractivechaos.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/attractivechaos.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/attractivechaos.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/attractivechaos.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/attractivechaos.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/attractivechaos.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/attractivechaos.wordpress.com/157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=attractivechaos.wordpress.com&blog=4545823&post=157&subd=attractivechaos&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://attractivechaos.wordpress.com/2008/08/22/improved-gnu-sort-from-textutils-122/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/047ebc7bb9ff37a0da844413856e92cb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">attractivechaos</media:title>
		</media:content>
	</item>
		<item>
		<title>Converting Source Codes to HTML</title>
		<link>http://attractivechaos.wordpress.com/2008/08/19/converting-source-codes-to-html/</link>
		<comments>http://attractivechaos.wordpress.com/2008/08/19/converting-source-codes-to-html/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 22:00:49 +0000</pubDate>
		<dc:creator>attractivechaos</dc:creator>
				<category><![CDATA[resources]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=45</guid>
		<description><![CDATA[If you use Emacs, you can convert everything you see on the screen to an HTML file with almost exactly the same look and style. The package you need is htmlize.el. Some Emacs distributions, such as Carbon Emacs, package this module by default. This page shows an example. Really fantastic! It goes far beyond any [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=attractivechaos.wordpress.com&blog=4545823&post=45&subd=attractivechaos&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>If you use Emacs, you can convert everything you see on the screen to an HTML file with almost exactly the same look and style. The package you need is <a href="http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el">htmlize.el</a>. Some Emacs distributions, such as Carbon Emacs, package this module by default. <a href="http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el.html">This page</a> shows an example. Really fantastic! It goes far beyond any similar methods I am aware of so far.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/attractivechaos.wordpress.com/45/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/attractivechaos.wordpress.com/45/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/attractivechaos.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/attractivechaos.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/attractivechaos.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/attractivechaos.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/attractivechaos.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/attractivechaos.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/attractivechaos.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/attractivechaos.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/attractivechaos.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/attractivechaos.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=attractivechaos.wordpress.com&blog=4545823&post=45&subd=attractivechaos&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://attractivechaos.wordpress.com/2008/08/19/converting-source-codes-to-html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/047ebc7bb9ff37a0da844413856e92cb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">attractivechaos</media:title>
		</media:content>
	</item>
	</channel>
</rss>