pub fn pivot<T: PartialOrd>(v: &mut [T]) -> usize {

    // using a rand number
    let mut p = b_rand::rand(v.len());
    // place rand on position 0
    v.swap( p, 0 );
    // p = 0
    p = 0;
    // ignore first, and iterate for each val
    for i in 1..v.len(){
        // if next val is lower than pivot val, pivot val must be after that value
        if v[i] < v[p] {
            v.swap(p + 1, i); // next val = i      12 {p}, 6 {i}, 10, 5  => 12 {p}, 1{i} *on first it, p+1 == i
                              // on next it,       6 {p}, 12{p+1}, 5{i} => so,  6->5->12
            v.swap(p, p + 1); // and...            5 -> 6 -> 12
            p += 1;
        }
    }
    p
}
// algorithm
// Move first element to correct plave
// Everything lower should be before it
// Everything hight should be after it
// return it's location
algorithm
Move first element to correct plave
Everything lower should be before it
Everything hight should be after it
return it's location
algorithm Move first element to correct plave Everything lower should be before it Everything hight should be after it return it ' s location
pub fn pivot<T: PartialOrd>(v: &mut [T]) -> usize {
    // using a rand number
    let mut p = b_rand::rand(v.len());
    // place rand on position 0
    v.swap( p, 0 );
    // p = 0
    p = 0;
    // ignore first, and iterate for each val
    for i in 1..v.len(){
        // if next val is lower than pivot val, pivot val must be after that value
        if v[i] < v[p] {
            v.swap(p + 1, i); // next val = i      12 {p}, 6 {i}, 10, 5  => 12 {p}, 1{i} *on first it, p+1 == i
                              // on next it,       6 {p}, 12{p+1}, 5{i} => so,  6->5->12
            v.swap(p, p + 1); // and...            5 -> 6 -> 12
            p += 1;
        }
    }
    p
}
pub fn pivot < T : PartialOrd > ( v : & mut [ T ] ) -> usize { // using a rand number let mut p = b_rand :: rand ( v . len ( ) ) ; // place rand on position 0 v . swap ( p , 0 ) ; // p = 0 p = 0 ; // ignore first, and iterate for each val for i in 1 .. v . len ( ) { // if next val is lower than pivot val, pivot val must be after that value if v [ i ] < v [ p ] { v . swap ( p + 1 , i ) ; // next val = i      12 {p}, 6 {i}, 10, 5  => 12 {p}, 1{i} *on first it, p+1 == i // on next it,       6 {p}, 12{p+1}, 5{i} => so,  6->5->12 v . swap ( p , p + 1 ) ; // and...            5 -> 6 -> 12 p += 1 ; } } p }
algorithm
Move first element to correct plave
Everything lower should be before it
Everything hight should be after it
return it's location
algorithm Move first element to correct plave Everything lower should be before it Everything hight should be after it return it ' s location
v
&mut [T]
v
&mut [T]