Skip to content

Commit 9fbee35

Browse files
committed
Add a test for sort_by_key
1 parent b8452cc commit 9fbee35

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/liballoc/tests/slice.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@ fn test_sort() {
425425
v.sort_by(|a, b| b.cmp(a));
426426
assert!(v.windows(2).all(|w| w[0] >= w[1]));
427427

428+
// Sort in lexicographic order.
429+
let mut v = orig.clone();
430+
v.sort_by_key(|x| x.to_string());
431+
assert!(v.windows(2).all(|w| w[0].to_string() <= w[1].to_string()));
432+
428433
// Sort with many pre-sorted runs.
429434
let mut v = orig.clone();
430435
v.sort();

0 commit comments

Comments
 (0)