MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / argsort_permutation_default

Function argsort_permutation_default

rust/stringzilla.rs:3695–3709  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3693
3694 #[test]
3695 fn argsort_permutation_default() {
3696 // Test with a slice of string literals.
3697 let fruits = ["banana", "apple", "cherry"];
3698 let mut order = [0; 3]; // output buffer must be at least fruits.len()
3699 sz::argsort_permutation(&fruits, &mut order).expect("argsort_permutation failed");
3700
3701 // Reconstruct sorted order using the returned indices.
3702 let sorted_from_api: Vec<_> = order.iter().map(|&i| fruits[i]).collect();
3703
3704 // Compute expected order using the standard sort.
3705 let mut expected = fruits.to_vec();
3706 expected.sort();
3707
3708 assert_eq!(sorted_from_api, expected);
3709 }
3710
3711 #[test]
3712 fn argsort_permutation_by_custom() {

Callers

nothing calls this directly

Calls 2

argsort_permutationFunction · 0.85
iterMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…