Sort order of dirEntries
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Oct 25 10:17:25 PDT 2012
On Thu, Oct 25, 2012 at 04:22:43PM +0200, Joseph Rushton Wakeling wrote:
> On 10/25/2012 02:30 AM, H. S. Teoh wrote:
> >This may not be possible if the OS doesn't keep the entries in sorted
> >order (and from what I know, most OS's don't; it's only sorted upon
> >display). *Somebody* will have to do the sorting, whether it's the
> >OS, or the library or user code. The performance penalty will still
> >be incurred regardless.
>
> ... and interestingly enough the sort order seems to be different
> depending on the choice of compiler.
Oh, really? I couldn't reproduce that effect on my system (Debian Linux
64-bit) with dmd (latest git) and gdc (git gdc-4.7 branch). I always get
the same ordering regardless of the compiler I used.
For reference, here's my code:
import std.file;
import std.stdio;
void main(string[] args) {
auto entries = dirEntries(args.length > 1 ? args[1] : ".",
SpanMode.shallow);
foreach (e; entries) {
writeln(e);
}
}
T
--
Those who don't understand Unix are condemned to reinvent it, poorly.
More information about the Digitalmars-d-learn
mailing list