<?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: Python listdir order</title>
	<atom:link href="http://zeta-puppis.com/2008/02/15/python-listdir-order/feed/" rel="self" type="application/rss+xml" />
	<link>http://zeta-puppis.com/2008/02/15/python-listdir-order/</link>
	<description>my very own personal corner</description>
	<lastBuildDate>Fri, 06 Jan 2012 03:20:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Sepero</title>
		<link>http://zeta-puppis.com/2008/02/15/python-listdir-order/comment-page-1/#comment-15864</link>
		<dc:creator>Sepero</dc:creator>
		<pubDate>Thu, 05 Jan 2012 03:21:05 +0000</pubDate>
		<guid isPermaLink="false">http://zeta-puppis.com/2008/02/15/python-listdir-order/#comment-15864</guid>
		<description>Ah, my indents got removed from the above comment. You can prolly figure it out. It removes directories from variable all into variable dirs. Then adds the files left in variable all to the end of variable dirs.</description>
		<content:encoded><![CDATA[<p>Ah, my indents got removed from the above comment. You can prolly figure it out. It removes directories from variable all into variable dirs. Then adds the files left in variable all to the end of variable&nbsp;dirs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sepero</title>
		<link>http://zeta-puppis.com/2008/02/15/python-listdir-order/comment-page-1/#comment-15863</link>
		<dc:creator>Sepero</dc:creator>
		<pubDate>Thu, 05 Jan 2012 03:16:46 +0000</pubDate>
		<guid isPermaLink="false">http://zeta-puppis.com/2008/02/15/python-listdir-order/#comment-15863</guid>
		<description>If you have a directory with 100,000 listings, you might want to write a more efficient code function. Here&#039;s a whack at it.
&lt;strong&gt;&lt;code&gt;
import os
def custom_listdir(path):
    &quot;&quot;&quot;
    Returns the content of a directory by showing directories first
    and then files by ordering the names alphabetically
    &quot;&quot;&quot;
    all = sorted(os.listdir(path)); dirs = []
        for i in xrange(len(all)-1, -1, -1):
            if os.path.isdir(path + os.path.sep + all[i]):
                dirs.append(all.pop(i))
    dirs.extend(all)
&lt;/code&gt;&lt;/strong&gt;</description>
		<content:encoded><![CDATA[<p>If you have a directory with 100,000 listings, you might want to write a more efficient code function. Here&#8217;s a whack at it.<br />
<strong><code><br />
import os<br />
def custom_listdir(path):<br />
    """<br />
    Returns the content of a directory by showing directories first<br />
    and then files by ordering the names alphabetically<br />
    """<br />
    all = sorted(os.listdir(path)); dirs = []<br />
        for i in xrange(len(all)-1, -1, -1):<br />
            if os.path.isdir(path + os.path.sep + all[i]):<br />
                dirs.append(all.pop(i))<br />
    dirs.extend(all)<br />
</code></strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://zeta-puppis.com/2008/02/15/python-listdir-order/comment-page-1/#comment-7810</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 24 Aug 2010 17:32:09 +0000</pubDate>
		<guid isPermaLink="false">http://zeta-puppis.com/2008/02/15/python-listdir-order/#comment-7810</guid>
		<description>Very nice, also if you use numpy you can also do something like this, using array&#039;s built in argsort method

import numpy

dirs=array(os.listdir(&#039;./&#039;))
dirs=dirs[dirs.argsort()]</description>
		<content:encoded><![CDATA[<p>Very nice, also if you use numpy you can also do something like this, using array&#8217;s built in argsort&nbsp;method</p>
<p>import&nbsp;numpy</p>
<p>dirs=array(os.listdir(&#8216;./&#8217;))<br />&nbsp;dirs=dirs[dirs.argsort()]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nicolo</title>
		<link>http://zeta-puppis.com/2008/02/15/python-listdir-order/comment-page-1/#comment-7602</link>
		<dc:creator>nicolo</dc:creator>
		<pubDate>Thu, 29 Jul 2010 09:55:57 +0000</pubDate>
		<guid isPermaLink="false">http://zeta-puppis.com/2008/02/15/python-listdir-order/#comment-7602</guid>
		<description>thx! very useful!</description>
		<content:encoded><![CDATA[<p>thx! very&nbsp;useful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cnewman</title>
		<link>http://zeta-puppis.com/2008/02/15/python-listdir-order/comment-page-1/#comment-7522</link>
		<dc:creator>cnewman</dc:creator>
		<pubDate>Tue, 13 Jul 2010 16:29:43 +0000</pubDate>
		<guid isPermaLink="false">http://zeta-puppis.com/2008/02/15/python-listdir-order/#comment-7522</guid>
		<description>Wow, awesome. Thanks</description>
		<content:encoded><![CDATA[<p>Wow, awesome.&nbsp;Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clem</title>
		<link>http://zeta-puppis.com/2008/02/15/python-listdir-order/comment-page-1/#comment-6437</link>
		<dc:creator>Clem</dc:creator>
		<pubDate>Tue, 12 Jan 2010 09:24:35 +0000</pubDate>
		<guid isPermaLink="false">http://zeta-puppis.com/2008/02/15/python-listdir-order/#comment-6437</guid>
		<description>Thanks a lot, it&#039;s exactly what I was looking for. Very useful.

Luca</description>
		<content:encoded><![CDATA[<p>Thanks a lot, it&#8217;s exactly what I was looking for. Very&nbsp;useful.</p>
<p>Luca</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giuliani Vito, Ivan</title>
		<link>http://zeta-puppis.com/2008/02/15/python-listdir-order/comment-page-1/#comment-188</link>
		<dc:creator>Giuliani Vito, Ivan</dc:creator>
		<pubDate>Wed, 25 Jun 2008 21:01:02 +0000</pubDate>
		<guid isPermaLink="false">http://zeta-puppis.com/2008/02/15/python-listdir-order/#comment-188</guid>
		<description>Thanks, fixed</description>
		<content:encoded><![CDATA[<p>Thanks,&nbsp;fixed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: falstaff</title>
		<link>http://zeta-puppis.com/2008/02/15/python-listdir-order/comment-page-1/#comment-185</link>
		<dc:creator>falstaff</dc:creator>
		<pubDate>Mon, 23 Jun 2008 19:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://zeta-puppis.com/2008/02/15/python-listdir-order/#comment-185</guid>
		<description>Cool!

But to use you have to add an s in the return statement... (return dirs)</description>
		<content:encoded><![CDATA[<p>Cool!</p>
<p>But to use you have to add an s in the return statement&#8230; (return&nbsp;dirs)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

