@@ -236,6 +236,53 @@ describe('sortFolderItems', () => {
236236 "------.md"
237237 ] )
238238 } )
239+ it ( 'should correctly order the week number with specifiers' , ( ) => {
240+ // given
241+ const processor : SortingSpecProcessor = new SortingSpecProcessor ( )
242+ const sortSpecTxt =
243+ `
244+ /+ \\[yyyy-Www]
245+ /+ \\[yyyy-mm-dd]
246+ > a-z
247+ `
248+ const PARENT_PATH = 'parent/folder/path'
249+ const sortSpecsCollection = processor . parseSortSpecFromText (
250+ sortSpecTxt . split ( '\n' ) ,
251+ PARENT_PATH ,
252+ 'file name with the sorting, irrelevant here'
253+ )
254+
255+ const folder : TFolder = mockTFolder ( PARENT_PATH , [
256+ // ISO and U.S. standard for 2025 give the same week numbers (remark for clarity)
257+ mockTFile ( '2025-03-09' , 'md' ) , // sunday of W10
258+ mockTFile ( '2025-W11-' , 'md' ) , // earlier than monday of W11
259+ mockTFile ( '2025-03-10' , 'md' ) , // monday W11
260+ mockTFile ( '2025-W11' , 'md' ) , // monday of W11
261+ mockTFile ( '2025-03-16' , 'md' ) , // sunday W11
262+ mockTFile ( '2025-W11+' , 'md' ) , // later than sunday W11 // expected
263+ mockTFile ( '2025-03-17' , 'md' ) , // monday of W12
264+ ] )
265+
266+ const sortSpec : CustomSortSpec = sortSpecsCollection ?. sortSpecByPath ! [ PARENT_PATH ] !
267+
268+ const ctx : ProcessingContext = { }
269+
270+ // when
271+ const result : Array < TAbstractFile > = sortFolderItems ( folder , folder . children , sortSpec , ctx , OS_alphabetical )
272+
273+ // then
274+ // U.S. standard of weeks numbering
275+ const orderedNames = result . map ( f => f . name )
276+ expect ( orderedNames ) . toEqual ( [
277+ "2025-03-17.md" ,
278+ '2025-W11+.md' ,
279+ "2025-03-16.md" ,
280+ '2025-W11.md' ,
281+ "2025-03-10.md" ,
282+ "2025-W11-.md" ,
283+ "2025-03-09.md" ,
284+ ] )
285+ } )
239286} )
240287
241288
0 commit comments