Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/JortSort/Rust/jortsort-1.rust
Normal file
16
Task/JortSort/Rust/jortsort-1.rust
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
use std::cmp::{Ord, Eq};
|
||||
|
||||
fn jort_sort<T: Ord + Eq + Clone>(array: Vec<T>) -> bool {
|
||||
// sort the array
|
||||
let mut sorted_array = array.to_vec();
|
||||
sorted_array.sort();
|
||||
|
||||
// compare to see if it was originally sorted
|
||||
for i in 0..array.len() {
|
||||
if array[i] != sorted_array[i] {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
12
Task/JortSort/Rust/jortsort-2.rust
Normal file
12
Task/JortSort/Rust/jortsort-2.rust
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
fn jort_sort<T>(slice: &[T]) -> bool
|
||||
where
|
||||
T: Ord + PartialEq + Clone,
|
||||
{
|
||||
let mut sorted = slice.to_vec();
|
||||
sorted.sort_unstable();
|
||||
|
||||
slice
|
||||
.iter()
|
||||
.zip(sorted.iter())
|
||||
.all(|(orig, sorted)| orig == sorted)
|
||||
}
|
||||
9
Task/JortSort/Rust/jortsort-3.rust
Normal file
9
Task/JortSort/Rust/jortsort-3.rust
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
fn jort_sort<T>(slice: &[T]) -> bool
|
||||
where
|
||||
T: Ord + PartialEq + Clone,
|
||||
{
|
||||
let mut sorted = slice.to_vec();
|
||||
sorted.sort_unstable();
|
||||
|
||||
slice == sorted
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue