@@ -2620,7 +2620,25 @@ const assertAndNormalizeFileUrl = (
26202620 return value ;
26212621} ;
26222622
2623- const comparePathnames = ( leftPathame , rightPathname ) => {
2623+ /*
2624+ * Which of two pathnames comes first: directories before what is under them,
2625+ * deeper before shallower, then the names themselves.
2626+ *
2627+ * How a leading number reads is the caller's call, because the two readings are
2628+ * both right somewhere:
2629+ * - numeric (the default), where the number is a quantity: "9_x" then "10_x" —
2630+ * what a generated list wants, so a story numbered by hand stays in the order
2631+ * it happens;
2632+ * - { numeric: false }, where the number is part of the name: "10_x" right
2633+ * after "1_x" — the order the filesystem itself gives, and the one every file
2634+ * explorer above it shows, so a human reading a directory finds it in the
2635+ * order their editor already shows.
2636+ */
2637+ const comparePathnames = (
2638+ leftPathame ,
2639+ rightPathname ,
2640+ { numeric = true } = { } ,
2641+ ) => {
26242642 const leftPartArray = leftPathame . split ( "/" ) ;
26252643 const rightPartArray = rightPathname . split ( "/" ) ;
26262644
@@ -2656,7 +2674,7 @@ const comparePathnames = (leftPathame, rightPathname) => {
26562674 i ++ ;
26572675 // local comparison comes first
26582676 const comparison = leftPart . localeCompare ( rightPart , undefined , {
2659- numeric : true ,
2677+ numeric,
26602678 sensitivity : "base" ,
26612679 } ) ;
26622680 if ( comparison !== 0 ) {
@@ -2673,8 +2691,8 @@ const comparePathnames = (leftPathame, rightPathname) => {
26732691 return 0 ;
26742692} ;
26752693
2676- const compareFileUrls = ( a , b ) => {
2677- return comparePathnames ( new URL ( a ) . pathname , new URL ( b ) . pathname ) ;
2694+ const compareFileUrls = ( a , b , options ) => {
2695+ return comparePathnames ( new URL ( a ) . pathname , new URL ( b ) . pathname , options ) ;
26782696} ;
26792697
26802698const isWindows$3 = process . platform === "win32" ;
0 commit comments