[Jslib] Dir.readDir()

Pete Collins pete at mozdevgroup.com
Mon Jan 15 04:55:01 PST 2007


Yea, try this:

var a = new Array;

for (var i=0;i<entries.length; i++) a.push(entries[i].path);

// sorted entries
var s = a.sort();

// print the sorted entries
for (i=0;i<s.length;i++) jslibPrint(s[i]);

Having readDir() sort them is something I will need to add ...


--pete


Greg Marine wrote:

> Pete,
>
> Thank you for your response. However, the issue I am having is in the 
> sort order of the files and directories on my Linux box. In Windows, 
> the sort is alphabetical. But in Linux, there doesn't appear to be any 
> rhyme or reason to the order in which the files and directories are 
> returned by readDir(). I want to have it sorted alphabetically.
>
> Thanks,
> Greg
>
> On 1/14/07, *Pete Collins* <pete at mozdevgroup.com 
> <mailto:pete at mozdevgroup.com>> wrote:
>
>
>
>     Greg Marine wrote:
>
>     > Hello,
>     >
>     > I'm having a sorting issue with the readDir() method of the Dir
>     > module. On WinXP, the files/folders are in alphabetical order.
>     > However, in Linux it won't sort alphabetically. I even attempted to
>     > using the sort() method for JavaScript arrays and it still
>     didn't sort
>     > correctly. Is this a bug?
>     >
>     > I appreciate your help!
>     >
>
>     The platform shouldn't matter since readDir returns a js array of the
>     entries ...
>
>     The entries are js File objects.
>
>     var e = d.readDir();
>
>     jslibPrint(e[0].path);
>
>       /tmp/foo
>
>     Hope this helps ...
>
>     --pete
>
>     --
>     Pete Collins - Founder, Mozdev Group Inc.
>     www.mozdevgroup.com <http://www.mozdevgroup.com>
>     Mozilla Software Development Solutions
>     tel: 1-719-302-5811
>     fax: 1-719-302-5813
>
>     _______________________________________________
>     Jslib mailing list
>     Jslib at mozdev.org <mailto:Jslib at mozdev.org>
>     http://mozdev.org/mailman/listinfo/jslib
>
>
>
>
> -- 
> Internet Community Church Ministries
> http://www.iccnet.org
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Jslib mailing list
>Jslib at mozdev.org
>http://mozdev.org/mailman/listinfo/jslib
>  
>

-- 
Pete Collins - Founder, Mozdev Group Inc.
www.mozdevgroup.com
Mozilla Software Development Solutions
tel: 1-719-302-5811
fax: 1-719-302-5813



More information about the Jslib mailing list