From 7a99b0a22f5e528ec5a729624903e238f6fb250a Mon Sep 17 00:00:00 2001
From: Shawn <65295172+tosky1125@users.noreply.github.com>
Date: Fri, 4 Jul 2025 20:54:24 +0200
Subject: [PATCH 1/3] Replace unmaintained human-sort with numeric-sort
human-sort is unmaintained and causes panic in recent Rust versions.
This commit replaces all usages of human_sort::compare with
numeric_sort::cmp to fix the 'total order' panic issue.
Fixes #1758
---
Cargo.lock | 14 +++++++-------
lychee-bin/Cargo.toml | 2 +-
lychee-bin/src/formatters/stats/compact.rs | 4 +++-
lychee-bin/src/formatters/stats/detailed.rs | 4 ++--
lychee-bin/src/formatters/stats/mod.rs | 6 ++++--
5 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 85f888065d..c92f7d4198 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1906,12 +1906,6 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
-[[package]]
-name = "human-sort"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "140a09c9305e6d5e557e2ed7cbc68e05765a7d4213975b87cb04920689cc6219"
-
[[package]]
name = "humantime"
version = "2.2.0"
@@ -2506,12 +2500,12 @@ dependencies = [
"headers",
"http 1.3.1",
"http-serde",
- "human-sort",
"humantime",
"humantime-serde",
"indicatif",
"log",
"lychee-lib",
+ "numeric-sort",
"openssl-sys",
"pad",
"predicates",
@@ -2786,6 +2780,12 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
+[[package]]
+name = "numeric-sort"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2dcb6053ab98da45585315f79932c5c9821fab8efa4301c0d7b637c91630eb7"
+
[[package]]
name = "object"
version = "0.36.7"
diff --git a/lychee-bin/Cargo.toml b/lychee-bin/Cargo.toml
index e68ac06909..35a0894fac 100644
--- a/lychee-bin/Cargo.toml
+++ b/lychee-bin/Cargo.toml
@@ -31,7 +31,7 @@ http = "1.3.1"
http-serde = "2.1.1"
humantime = "2.2.0"
humantime-serde = "1.1.1"
-human-sort = "0.2.2"
+numeric-sort = "0.1.5"
indicatif = "0.17.11"
log = "0.4.27"
openssl-sys = { version = "0.9.108", optional = true }
diff --git a/lychee-bin/src/formatters/stats/compact.rs b/lychee-bin/src/formatters/stats/compact.rs
index 74b5e38a81..d92052f59b 100644
--- a/lychee-bin/src/formatters/stats/compact.rs
+++ b/lychee-bin/src/formatters/stats/compact.rs
@@ -11,6 +11,8 @@ use crate::{formatters::get_response_formatter, options, stats::ResponseStats};
use super::StatsFormatter;
+use numeric_sort::cmp;
+
struct CompactResponseStats {
stats: ResponseStats,
mode: options::OutputMode,
@@ -52,7 +54,7 @@ impl Display for CompactResponseStats {
let mut sorted_suggestions: Vec<_> = suggestions.iter().collect();
sorted_suggestions.sort_by(|a, b| {
let (a, b) = (a.to_string().to_lowercase(), b.to_string().to_lowercase());
- human_sort::compare(&a, &b)
+ cmp(&a, &b)
});
writeln!(f, "\n\u{2139} Suggestions")?;
diff --git a/lychee-bin/src/formatters/stats/detailed.rs b/lychee-bin/src/formatters/stats/detailed.rs
index 696f7b3ec0..4ea4adcb8f 100644
--- a/lychee-bin/src/formatters/stats/detailed.rs
+++ b/lychee-bin/src/formatters/stats/detailed.rs
@@ -4,7 +4,7 @@ use crate::{formatters::get_response_formatter, options, stats::ResponseStats};
use anyhow::Result;
use pad::{Alignment, PadStr};
use std::fmt::{self, Display};
-
+use numeric_sort::cmp;
// Maximum padding for each entry in the final statistics output
const MAX_PADDING: usize = 20;
@@ -68,7 +68,7 @@ impl Display for DetailedResponseStats {
let mut sorted_suggestions: Vec<_> = suggestions.iter().collect();
sorted_suggestions.sort_by(|a, b| {
let (a, b) = (a.to_string().to_lowercase(), b.to_string().to_lowercase());
- human_sort::compare(&a, &b)
+ cmp(&a, &b)
});
writeln!(f, "\nSuggestions in {source}")?;
diff --git a/lychee-bin/src/formatters/stats/mod.rs b/lychee-bin/src/formatters/stats/mod.rs
index 00e3c54bf5..9744e2bac2 100644
--- a/lychee-bin/src/formatters/stats/mod.rs
+++ b/lychee-bin/src/formatters/stats/mod.rs
@@ -19,6 +19,8 @@ use crate::stats::ResponseStats;
use anyhow::Result;
use lychee_lib::InputSource;
+use numeric_sort::cmp;
+
pub(crate) trait StatsFormatter {
/// Format the stats of all responses and write them to stdout
fn format(&self, stats: ResponseStats) -> Result