File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,12 +23,32 @@ function humanize(name: string): string {
2323 . replace ( / \b \w / g, c => c . toUpperCase ( ) )
2424}
2525
26+ // 学习顺序:入门准备 → Docker环境 → U-Boot → 内核 → 文件系统 → 驱动 → 实战 → 进阶
27+ const LEARNING_ORDER = [
28+ 'start' ,
29+ 'docker' ,
30+ 'uboot' ,
31+ 'kernel' ,
32+ 'rootfs' ,
33+ 'driver' ,
34+ 'practical' ,
35+ 'third_party' ,
36+ ]
37+
2638function sortEntries ( a : string , b : string ) : number {
2739 const na = a . match ( / ^ ( \d + ) / ) ?. [ 1 ]
2840 const nb = b . match ( / ^ ( \d + ) / ) ?. [ 1 ]
2941 if ( na && nb ) return parseInt ( na ) - parseInt ( nb )
3042 if ( na ) return - 1
3143 if ( nb ) return 1
44+
45+ // 对于没有数字前缀的目录,按学习顺序排序
46+ const ia = LEARNING_ORDER . indexOf ( a )
47+ const ib = LEARNING_ORDER . indexOf ( b )
48+ if ( ia !== - 1 && ib !== - 1 ) return ia - ib
49+ if ( ia !== - 1 ) return - 1
50+ if ( ib !== - 1 ) return 1
51+
3252 return a . localeCompare ( b , 'en' )
3353}
3454
You can’t perform that action at this time.
0 commit comments