Noticed we flipped the sort somewhere along the way. corrected that and added in your suggestion above as well as a trap for “there are less than 5 files”.
(tuple string items ((integers in (it-1,maximum of (it-5;0))) of (number of tuple string items of it)) of it)
This is getting pretty crisp!
Overall Folder contents
(yea, I have a lot of junk in my test box…)
q: (modification time of it, name of it) of files of folders ("/tmp";"c:\test")
A: ( Fri, 29 Jan 2021 17:55:23 -0500 ), Abc_20210115612456.txt
A: ( Fri, 29 Jan 2021 17:55:13 -0500 ), Abc_20210120342156.txt
A: ( Wed, 27 Jan 2021 12:58:49 -0500 ), Abc_20210121225468.txt
A: ( Fri, 29 Jan 2021 17:54:44 -0500 ), Abc_20210123165009.txt
A: ( Wed, 27 Jan 2021 12:59:09 -0500 ), Abc_20210124184449.txt
A: ( Fri, 29 Jan 2021 17:54:53 -0500 ), Abc_20210125205107.txt
A: ( Fri, 29 Jan 2021 17:55:04 -0500 ), Abc_20210126224733.txt
A: ( Wed, 01 Apr 2020 11:16:41 -0500 ), DLV cscript command.txt
A: ( Wed, 01 Apr 2020 11:16:10 -0500 ), DLV parse for Win 7.qna
A: ( Wed, 01 Apr 2020 11:15:47 -0500 ), dlv.txt
A: ( Tue, 02 Jun 2020 14:24:49 -0500 ), Fake.txt
A: ( Fri, 06 Dec 2019 11:16:00 -0500 ), Install Multiple Activation Key.url
A: ( Wed, 01 Apr 2020 11:43:49 -0500 ), LicenseStatus Values.url
A: ( Wed, 27 Jan 2021 12:59:17 -0500 ), one more file 5.txt
A: ( Wed, 01 Apr 2020 11:26:43 -0500 ), Screenshot mapping WMI entries to SLMGR DLV entries.png
A: ( Tue, 14 Jan 2020 13:10:59 -0500 ), slmgr into file.url
A: ( Thu, 04 Feb 2021 12:23:31 -0500 ), test1_20210123165009.txt
A: ( Thu, 04 Feb 2021 12:23:15 -0500 ), test2_20210124184449.txt
A: ( Wed, 27 Jan 2021 12:59:02 -0500 ), test3_20210125205107.txt
A: ( Wed, 27 Jan 2021 12:58:56 -0500 ), test4_20210126224733.txt
A: ( Wed, 01 Apr 2020 13:44:07 -0500 ), WMI style DLV answer v2.qna
A: ( Wed, 01 Apr 2020 13:44:29 -0500 ), WMI style DLV answer v3.qna
A: ( Wed, 01 Apr 2020 11:19:48 -0500 ), WMI style DLV answer.qna
T: 14.074 ms
I: plural ( time, string )
Code without the final collapse, to show the dates in order.
q: (((tuple string items ((integers in (it-1,maximum of (it-5;0))) of (number of tuple string items of it)) of it) of concatenation ", " of following texts of firsts ", " of (it as string) of unique values of (it as time) of tuple string items 1 of elements of it), ((tuple string items 0 of it, tuple string items 1 of it) of elements of it)) whose (item 0 of it = item 1 of item 1 of it) of set of (it as string) of (name of it, following text of first ", " of (it as string) of modification time of it) of files of folders ("/tmp";"c:\test")
A: 04 Feb 2021 12:23:31 -0500, ( test1_20210123165009.txt, 04 Feb 2021 12:23:31 -0500 )
A: 04 Feb 2021 12:23:15 -0500, ( test2_20210124184449.txt, 04 Feb 2021 12:23:15 -0500 )
A: 29 Jan 2021 17:55:23 -0500, ( Abc_20210115612456.txt, 29 Jan 2021 17:55:23 -0500 )
A: 29 Jan 2021 17:55:13 -0500, ( Abc_20210120342156.txt, 29 Jan 2021 17:55:13 -0500 )
A: 29 Jan 2021 17:55:04 -0500, ( Abc_20210126224733.txt, 29 Jan 2021 17:55:04 -0500 )
T: 11.200 ms
I: plural ( string, ( string, string ) )
Current full code for optimized newest 5 files in folder with reverse sort by modification date
q: items 0 of items 1 of (((tuple string items ((integers in (it-1,maximum of (it-5;0))) of (number of tuple string items of it)) of it) of concatenation ", " of following texts of firsts ", " of (it as string) of unique values of (it as time) of tuple string items 1 of elements of it), ((tuple string items 0 of it, tuple string items 1 of it) of elements of it)) whose (item 0 of it = item 1 of item 1 of it) of set of (it as string) of (name of it, following text of first ", " of (it as string) of modification time of it) of files of folders ("/tmp";"c:\test")
A: test1_20210123165009.txt
A: test2_20210124184449.txt
A: Abc_20210115612456.txt
A: Abc_20210120342156.txt
A: Abc_20210126224733.txt
T: 6.582 ms
I: plural string
And with indention and comments (hint - comments are bottom up to follow the logical flow)
