Repository: flxzt/rnote (language: rust)

Issue:
Numbered files get sorted in an unexpected/non-sequential manner in the sidebar
**Describe the bug**  
Files with sequential numbers in them are sorted in an unexpected manner (sorted by each individual numeral character, not by the whole number's sequential value)

**To Reproduce**  
Steps to reproduce the behavior:
1. Create some folders/files that span 0-25ish
2. See that the list reads like: 1, 10, 11, 12, ... 19, 2, 20, 21...

**Expected behavior**  
Numbered files should follow in sequential order of the number's value.

**Screenshots**  
![image](https://github.com/flxzt/rnote/assets/55755379/f40a1d0c-ec41-4af4-a8ac-c1f2407cf5e4)

**Desktop (please complete the following information):**  
 - OS: Fedora 39
 - App Version: Rnote 0.9.0
 - Installation Source: Flatpak/Flathub remote
 - Desktop Environment: Gnome 45



Discussion / hints:

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index f2f6f84cd7..991a9b3da6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2551,6 +2551,12 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "no-std-compat"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"
+
 [[package]]
 name = "nom"
 version = "7.1.3"
@@ -2661,6 +2667,15 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
 
+[[package]]
+name = "numeric-sort"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5f2c4adf593c928171160e2632096353bb0306d3c8447143861374d5e678e37"
+dependencies = [
+ "no-std-compat",
+]
+
 [[package]]
 name = "objc"
 version = "0.2.7"
@@ -3379,6 +3394,7 @@ dependencies = [
  "nalgebra",
  "num-derive 0.4.1",
  "num-traits",
+ "numeric-sort",
  "once_cell",
  "open",
  "parry2d-f64",
diff --git a/Cargo.toml b/Cargo.toml
index c93c23e6a4..5e64cc09e8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -79,6 +79,7 @@ librsvg = "2.57"
 poppler-rs = { version = "0.22", features = ["v20_9"] }
 gtk4 = { version = "0.7.3", features = ["v4_12"] }
 adw = { version = "0.5.3", package="libadwaita", features = ["v1_4"] }
+numeric-sort = "0.1"
 
 [patch.crates-io]
 # once a new piet (current v0.6.2) is released with the updated cairo, this can be removed
diff --git a/crates/rnote-ui/Cargo.toml b/crates/rnote-ui/Cargo.toml
index d47f217b2c..a3652eefe0 100644
--- a/crates/rnote-ui/Cargo.toml
+++ b/crates/rnote-ui/Cargo.toml
@@ -50,6 +50,7 @@ gettext-rs = {workspace = true }
 gtk4 = { workspace = true }
 adw = { workspace = true }
 open = { workspace = true }
+numeric-sort = {  workspace = true }
 
 [build-dependencies]
 anyhow = { workspace = true }
diff --git a/crates/rnote-ui/src/workspacebrowser/mod.rs b/crates/rnote-ui/src/workspacebrowser/mod.rs
index 19241a053a..16a0262348 100644
--- a/crates/rnote-ui/src/workspacebrowser/mod.rs
+++ b/crates/rnote-ui/src/workspacebrowser/mod.rs
@@ -398,7 +398,7 @@ impl RnWorkspaceBrowser {
             let second_display_name = second_file.basename().unwrap();
             let second_display_name = second_display_name.to_str().unwrap();
 
-            first_display_name.cmp(second_display_name).into()
+            numeric_sort::cmp(first_display_name, second_display_name).into()
         });
 
         let multisorter = MultiSorter::new();


Test patch: