Skip to content

Commit a6fe590

Browse files
committed
Use natural ordering for repo file names
1 parent e8f8a40 commit a6fe590

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vault-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ http-body-util = "0.1.3"
1717
lazy_static = "1.5.0"
1818
log = "0.4.29"
1919
md5 = "0.7.0"
20+
natord = "1.0.9"
2021
phf = { version = "0.11.3", features = ["macros"] }
2122
pin-project-lite = "0.2.16"
2223
# rand_core cannot be upgraded to > 0.6 because vault-crypto depends on

vault-core/src/repo_files/selectors.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ where
303303
match field {
304304
RepoFilesSortField::Name => {
305305
dirs.sort_by(|a, b| {
306-
direction.ordering(a.name_lower_force().cmp(b.name_lower_force()))
306+
direction.ordering(natord::compare(a.name_lower_force(), b.name_lower_force()))
307307
});
308308
files.sort_by(|a, b| {
309-
direction.ordering(a.name_lower_force().cmp(b.name_lower_force()))
309+
direction.ordering(natord::compare(a.name_lower_force(), b.name_lower_force()))
310310
});
311311
}
312312
RepoFilesSortField::Size => {
@@ -333,7 +333,7 @@ where
333333
match field {
334334
RepoFilesSortField::Name => {
335335
files.sort_by(|a, b| {
336-
direction.ordering(a.name_lower_force().cmp(b.name_lower_force()))
336+
direction.ordering(natord::compare(a.name_lower_force(), b.name_lower_force()))
337337
});
338338
}
339339
RepoFilesSortField::Size => {
@@ -670,7 +670,7 @@ mod tests {
670670
},
671671
);
672672

673-
assert_eq!(asc, vec!["19foo.txt", "1foo.txt", "2foo.txt"]);
673+
assert_eq!(asc, vec!["1foo.txt", "2foo.txt", "19foo.txt"]);
674674
}
675675

676676
#[test]
@@ -690,7 +690,7 @@ mod tests {
690690
},
691691
);
692692

693-
assert_eq!(asc, vec!["1 foo.txt", "19 foo.txt", "2 foo.txt"]);
693+
assert_eq!(asc, vec!["1 foo.txt", "2 foo.txt", "19 foo.txt"]);
694694
}
695695

696696
#[test]
@@ -710,7 +710,7 @@ mod tests {
710710
},
711711
);
712712

713-
assert_eq!(asc, vec!["foo1.txt", "foo19.txt", "foo2.txt"]);
713+
assert_eq!(asc, vec!["foo1.txt", "foo2.txt", "foo19.txt"]);
714714
}
715715

716716
#[test]
@@ -730,6 +730,6 @@ mod tests {
730730
},
731731
);
732732

733-
assert_eq!(asc, vec!["foo 1.txt", "foo 19.txt", "foo 2.txt"]);
733+
assert_eq!(asc, vec!["foo 1.txt", "foo 2.txt", "foo 19.txt"]);
734734
}
735735
}

0 commit comments

Comments
 (0)