File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,14 @@ const groupFilesByExt = (filenames: string[]) =>
13
13
filenames . reduce (
14
14
( { html, md } , filename ) => ( {
15
15
html : filename . match ( / h t m l $ / ) ? [ filename , ...html ] : html ,
16
- md : ( filename . match ( / m d $ / ) ? [ filename , ...md ] : md ) . sort (
17
- ( a : string , b : string ) =>
18
- parseInt ( basename ( a . substr ( 0 , 4 ) ) ) >
19
- parseInt ( basename ( b . substr ( 0 , 4 ) ) )
20
- ? 1
21
- : 0 ,
16
+ md : ( filename . match ( / m d $ / ) ? [ filename , ...md ] : md ) . toSorted (
17
+ ( a : string , b : string ) => {
18
+ const aInt = parseInt ( basename ( a ) . substr ( 0 , 4 ) ) ;
19
+ const bInt = parseInt ( basename ( b ) . substr ( 0 , 4 ) ) ;
20
+ if ( Number . isNaN ( b ) ) return - 1 ;
21
+ if ( Number . isNaN ( a ) ) return 1 ;
22
+ return aInt - bInt ;
23
+ } ,
22
24
) ,
23
25
} ) ,
24
26
{ html : [ ] as string [ ] , md : [ ] as string [ ] } ,
You can’t perform that action at this time.
0 commit comments