1- use std:: collections:: HashMap ;
1+ use std:: collections:: { BTreeMap as Map , HashMap } ;
22use std:: fs:: { self , create_dir_all, File , OpenOptions } ;
33use std:: io:: { self , BufRead , BufReader , BufWriter , Result } ;
44use std:: path:: { Path , PathBuf } ;
@@ -70,7 +70,7 @@ pub fn expand_spaced_seed_mask(spaced_seed_mask: u64, bit_expansion_factor: u64)
7070}
7171
7272pub fn find_files < P : AsRef < Path > > ( path : P , prefix : & str , suffix : & str ) -> Vec < PathBuf > {
73- WalkDir :: new ( path)
73+ let mut files : Vec < PathBuf > = WalkDir :: new ( path)
7474 . into_iter ( )
7575 . filter_map ( |e| e. ok ( ) )
7676 . filter ( |e| {
@@ -81,7 +81,9 @@ pub fn find_files<P: AsRef<Path>>(path: P, prefix: &str, suffix: &str) -> Vec<Pa
8181 . unwrap_or ( false )
8282 } )
8383 . map ( |e| e. path ( ) . to_path_buf ( ) )
84- . collect ( )
84+ . collect ( ) ;
85+ files. sort_unstable ( ) ;
86+ files
8587}
8688
8789pub fn format_bytes ( size : f64 ) -> String {
@@ -193,7 +195,7 @@ pub fn find_and_trans_files(
193195 prefix : & str ,
194196 suffix : & str ,
195197 check : bool ,
196- ) -> io:: Result < HashMap < usize , PathBuf > > {
198+ ) -> io:: Result < Map < usize , PathBuf > > {
197199 // 构建正则表达式以匹配文件名中的数字
198200 let pattern = format ! ( r"{}_(\d+){}" , prefix, suffix) ;
199201 let re = Regex :: new ( & pattern) . unwrap ( ) ;
@@ -212,8 +214,8 @@ pub fn find_and_trans_files(
212214 } )
213215 . collect :: < Vec < PathBuf > > ( ) ;
214216
215- // 使用正则表达式提取数字,并将它们存入HashMap
216- let mut map_entries = HashMap :: new ( ) ;
217+ // 使用正则表达式提取数字,并将它们存入BTreeMap
218+ let mut map_entries = Map :: new ( ) ;
217219 for path in entries {
218220 if let Some ( fname) = path. file_name ( ) . and_then ( |name| name. to_str ( ) ) {
219221 if let Some ( cap) = re. captures ( fname) {
0 commit comments