Sort naturally

This commit is contained in:
Jeremy Soller 2024-01-05 09:44:47 -07:00
parent 3888282687
commit 2d0a0059d3
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
3 changed files with 18 additions and 1 deletions

16
Cargo.lock generated
View file

@ -199,6 +199,12 @@ dependencies = [
"libc",
]
[[package]]
name = "any_ascii"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70033777eb8b5124a81a1889416543dddef2de240019b674c81285a2635a7e1e"
[[package]]
name = "apply"
version = "0.3.0"
@ -945,6 +951,7 @@ dependencies = [
"i18n-embed",
"i18n-embed-fl",
"lazy_static",
"lexical-sort",
"libcosmic",
"log",
"rust-embed",
@ -2706,6 +2713,15 @@ dependencies = [
"static_assertions",
]
[[package]]
name = "lexical-sort"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c09e4591611e231daf4d4c685a66cb0410cc1e502027a20ae55f2bb9e997207a"
dependencies = [
"any_ascii",
]
[[package]]
name = "libc"
version = "0.2.151"

View file

@ -7,6 +7,7 @@ edition = "2021"
dirs = "5.0.1"
env_logger = "0.10"
lazy_static = "1"
lexical-sort = "0.3.1"
log = "0.4"
serde = { version = "1", features = ["serde_derive"] }
tokio = { version = "1" }

View file

@ -201,7 +201,7 @@ pub fn rescan(tab_path: PathBuf) -> Vec<Item> {
items.sort_by(|a, b| match (a.is_dir, b.is_dir) {
(true, false) => Ordering::Less,
(false, true) => Ordering::Greater,
_ => a.name.cmp(&b.name),
_ => lexical_sort::natural_lexical_cmp(&a.name, &b.name),
});
items
}