www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Array merge and sort

reply Vino.B <vino.bheeman hotmail.com> writes:
Hi All,

  My code output's the below so can any one help me on hot to 
merege all tese array and sort the same.

Output :
[ Tuple!(string, string)("C:\\Temp\\TEST1\\BACKUP\\DND1.pdf", 
"2017-Sep-06 16:06:42") ]
[ Tuple!(string, string)("C:\\Temp\\TEST2\\EXPORT\\DND1.pdf", 
"2017-Sep-06 16:06:43")]
[ Tuple!(string, string)("C:\\Temp\\TEST3\\PROD_TEAM\\DND1.pdf", 
"2017-Sep-06 16:06:43")]
[ Tuple!(string, string)("C:\\Temp\\TEST4\\TEAM\\DND1.pdf", 
"2017-Sep-06 16:06:44") ]

Code :
foreach (string FFs; parallel(CleanDirlst[0 .. $], 1)) {
	MCresult.get ~= coCleanFiles(FFs.strip, Step);
	}
	foreach(i; MCresult.toRange)
		if (!i.empty) { writefln("%(%-(%-63s %s %)\n%)", i[]); }


From,
Vino.B
Sep 19
parent Jordan Wilson <wilsonjord gmail.com> writes:
On Wednesday, 20 September 2017 at 06:29:17 UTC, Vino.B wrote:
 Hi All,

  My code output's the below so can any one help me on hot to 
 merege all tese array and sort the same.

 Output :
 [ Tuple!(string, string)("C:\\Temp\\TEST1\\BACKUP\\DND1.pdf", 
 "2017-Sep-06 16:06:42") ]
 [ Tuple!(string, string)("C:\\Temp\\TEST2\\EXPORT\\DND1.pdf", 
 "2017-Sep-06 16:06:43")]
 [ Tuple!(string, 
 string)("C:\\Temp\\TEST3\\PROD_TEAM\\DND1.pdf", "2017-Sep-06 
 16:06:43")]
 [ Tuple!(string, string)("C:\\Temp\\TEST4\\TEAM\\DND1.pdf", 
 "2017-Sep-06 16:06:44") ]

 Code :
 foreach (string FFs; parallel(CleanDirlst[0 .. $], 1)) {
 	MCresult.get ~= coCleanFiles(FFs.strip, Step);
 	}
 	foreach(i; MCresult.toRange)
 		if (!i.empty) { writefln("%(%-(%-63s %s %)\n%)", i[]); }


 From,
 Vino.B
I'm not sure what MCresult is, but perhaps using joiner can help you. import std.algorithm : joiner, sort; import std.range : array; import std.typecons : Tuple; auto data = [[Tuple!(string,string)("test4","1")], [Tuple!(string,string)("test3","4"),Tuple!(string,string)("test2","3")], [Tuple!(string,string)("test1","2")]]; auto sortedData = data.joiner .array .sort!((a,b) => a[0] < b[0]); sortedData.writeln; // outputs // [Tuple!(string, string)("test1", "2"), Tuple!(string, string)("test2", "3"), Tuple!(string, string)("test3", "4"), Tuple!(string, string)("test4", "1")] Jordan
Sep 20