fn insert(mut queue: Vec<Node>, value: Node) -> Vec<Node> {
    let mut inserted = false;
    let mut previous = 0;
    for i in 0..queue.len() {
        if previous < value.total_weight && queue[i].total_weight >= value.total_weight {
            queue.insert(i, value);
            inserted = true;
        }
        previous = queue[i].total_weight;
    }

    if !inserted {
        queue.push(value);
    }

    queue
}
// insert so that it remains sorted
insert so that it remains sorted
insert so that it remains sorted
fn insert(mut queue: Vec<Node>, value: Node) -> Vec<Node> {
    let mut inserted = false;
    let mut previous = 0;
    for i in 0..queue.len() {
        if previous < value.total_weight && queue[i].total_weight >= value.total_weight {
            queue.insert(i, value);
            inserted = true;
        }
        previous = queue[i].total_weight;
    }
    if !inserted {
        queue.push(value);
    }
    queue
}
fn insert ( mut queue : Vec < Node > , value : Node ) -> Vec < Node > { let mut inserted = false ; let mut previous = 0 ; for i in 0 .. queue . len ( ) { if previous < value . total_weight && queue [ i ] . total_weight >= value . total_weight { queue . insert ( i , value ) ; inserted = true ; } previous = queue [ i ] . total_weight ; } if ! inserted { queue . push ( value ) ; } queue }
insert so that it remains sorted
insert so that it remains sorted
queue
Vec<Node>
value
Node
queue
Vec<Node>
value
Node