digitalmars.D.learn - Array merge and sort
- Vino.B (20/20) Sep 19 2017 Hi All,
- Jordan Wilson (19/40) Sep 20 2017 I'm not sure what MCresult is, but perhaps using joiner can help
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 2017
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.BI'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 2017