Tuple Array Sorting

Seb seb at wilzba.ch
Mon Dec 11 19:23:40 UTC 2017


On Monday, 11 December 2017 at 16:15:14 UTC, Vino wrote:
> On Monday, 11 December 2017 at 15:54:11 UTC, Biotronic wrote:
>>   [...]
>
> Hi Biotronic,
>
>  I tried your code with multiple folder's , but no luck the 
> output is not sorted.
>
> Program:
> import std.algorithm: filter, map, sort;
> import std.array;
> import std.file: SpanMode, dirEntries, isDir ;
> import std.stdio: writefln, writeln;
> import std.typecons: Tuple, tuple;
>
> void main () {
> auto FFs =  ["C:\\Temp\\sapnas2\\BACKUP", 
> "C:\\Temp\\sapnas2\\EXPORT", "C:\\Temp\\sapnas2\\PROD_TEAM"];
> auto sorted = FFs
> .map!(a => dirEntries(a, SpanMode.shallow))
> .join
> .filter!(a => a.isDir)
> .map!(a => tuple(a.name, a.timeCreated.toSimpleString[0 .. 20]))
> .array
> .sort!((a,b) => a[1] > b[1]);
> writefln("%( %( %-63s %s %) \n%)", sorted);
> }
>
> From,
> Vino.B

Your program still contains toSimpleString in the sort lambda. 
Have you, as suggested, removed it?
As Biotronic explained, sorting on the string representation of 
dates can't work.


More information about the Digitalmars-d-learn mailing list