Container Array or tuples Sorting

Vino vino.bheeman at hotmail.com
Wed Dec 13 15:16:50 UTC 2017


Hi All,

  Request your help, on how to sort a tuple container array, I 
have raised the same topic in one of the other thread "Tuple 
Array Sorting" and was addressed to use standard array rather 
than container array, and i am not able to find any document or 
example in the library for the same.

Eg: Program.
import std.algorithm: filter, map, sort;
import std.container.array;
import std.file: SpanMode, dirEntries, isDir ;
import std.stdio: writeln;
import std.typecons: Tuple, tuple;
import std.datetime.systime: SysTime;

void main () {
auto FFs =  ["C:\\Temp\\BACKUP", "C:\\Temp\\EXPORT"];
Array!(Tuple!(string, SysTime)) Result;
foreach(d; FFs[]) {
auto dFiles = Array!(Tuple!(string, SysTime))(dirEntries(d, 
SpanMode.shallow).filter!(a => a.isDir)
	.sort!((a,b) => a.timeCreated > b.timeCreated)
	.map!(a => tuple(a.name, a.timeCreated)));
writeln(dFiles[]);
} }

From,
Vino.B



More information about the Digitalmars-d-learn mailing list