Use custom crate for lexicographical sorting

This commit is contained in:
Tobie Morgan Hitchcock 2023-03-26 22:13:43 +01:00
parent 26a040df85
commit 13fe68a871
3 changed files with 10 additions and 16 deletions

18
Cargo.lock generated
View file

@ -264,12 +264,6 @@ dependencies = [
"libc",
]
[[package]]
name = "any_ascii"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70033777eb8b5124a81a1889416543dddef2de240019b674c81285a2635a7e1e"
[[package]]
name = "any_ascii"
version = "0.3.2"
@ -2050,12 +2044,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "lexical-sort"
version = "0.3.1"
name = "lexicmp"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c09e4591611e231daf4d4c685a66cb0410cc1e502027a20ae55f2bb9e997207a"
checksum = "7378d131ddf24063b32cbd7e91668d183140c4b3906270635a4d633d1068ea5d"
dependencies = [
"any_ascii 0.1.7",
"any_ascii",
]
[[package]]
@ -3615,7 +3609,7 @@ name = "surrealdb"
version = "1.0.0-beta.8"
dependencies = [
"addr",
"any_ascii 0.3.2",
"any_ascii",
"argon2",
"async-channel",
"async-executor",
@ -3634,7 +3628,7 @@ dependencies = [
"geo",
"indexmap",
"indxdb",
"lexical-sort",
"lexicmp",
"log",
"md-5",
"nanoid",

View file

@ -71,7 +71,7 @@ geo = { version = "0.24.1", features = ["use-serde"] }
indexmap = { version = "1.9.3", features = ["serde"] }
indxdb = { version = "0.3.0", optional = true }
js = { version = "0.1.7", package = "rquickjs", features = ["array-buffer", "bindgen", "classes", "futures", "loader", "macro", "parallel", "properties"], optional = true }
lexical-sort = "0.3.1"
lexicmp = "0.1.0"
log = "0.4.17"
md-5 = "0.10.5"
msgpack = { version = "1.1.1", package = "rmp-serde" }

View file

@ -1331,7 +1331,7 @@ impl Value {
/// Compare this Value to another Value lexicographically
pub fn lexical_cmp(&self, other: &Value) -> Option<Ordering> {
match (self, other) {
(Value::Strand(a), Value::Strand(b)) => Some(lexical_sort::lexical_cmp(a, b)),
(Value::Strand(a), Value::Strand(b)) => Some(lexicmp::lexical_cmp(a, b)),
_ => self.partial_cmp(other),
}
}
@ -1339,7 +1339,7 @@ impl Value {
/// Compare this Value to another Value using natrual numerical comparison
pub fn natural_cmp(&self, other: &Value) -> Option<Ordering> {
match (self, other) {
(Value::Strand(a), Value::Strand(b)) => Some(lexical_sort::natural_cmp(a, b)),
(Value::Strand(a), Value::Strand(b)) => Some(lexicmp::natural_cmp(a, b)),
_ => self.partial_cmp(other),
}
}
@ -1347,7 +1347,7 @@ impl Value {
/// Compare this Value to another Value lexicographically and using natrual numerical comparison
pub fn natural_lexical_cmp(&self, other: &Value) -> Option<Ordering> {
match (self, other) {
(Value::Strand(a), Value::Strand(b)) => Some(lexical_sort::natural_lexical_cmp(a, b)),
(Value::Strand(a), Value::Strand(b)) => Some(lexicmp::natural_lexical_cmp(a, b)),
_ => self.partial_cmp(other),
}
}