fn merge(&self, l: &[i64], r: &[i64], steps: &mut Vec<serde_json::Value>) -> Vec<i64> {
        let mut merged = Vec::new();

        let (mut left_idx, mut right_idx) = (0, 0);

        while left_idx < l.len() && right_idx < r.len() {
            if l[left_idx] <= r[right_idx] {
                merged.push(l[left_idx]);
                left_idx += 1;
            } else {
                merged.push(r[right_idx]);
                right_idx += 1;
            }

            steps.push(self.step(StepAction::Merge(&merged)));
        }

        while left_idx < l.len() {
            merged.push(l[left_idx]);
            left_idx += 1;
            steps.push(self.step(StepAction::Merge(&merged)));
        }

        while right_idx < r.len() {
            merged.push(r[right_idx]);
            right_idx += 1;
            steps.push(self.step(StepAction::Merge(&merged)));
        }

        merged
    }
///
/// Perform the merging of the two lists for Merge Sort.
///
Perform the merging of the two lists for Merge Sort.
Perform the merging of the two lists for Merge Sort .
fn merge(&self, l: &[i64], r: &[i64], steps: &mut Vec<serde_json::Value>) -> Vec<i64> {
        let mut merged = Vec::new();
        let (mut left_idx, mut right_idx) = (0, 0);
        while left_idx < l.len() && right_idx < r.len() {
            if l[left_idx] <= r[right_idx] {
                merged.push(l[left_idx]);
                left_idx += 1;
            } else {
                merged.push(r[right_idx]);
                right_idx += 1;
            }
            steps.push(self.step(StepAction::Merge(&merged)));
        }
        while left_idx < l.len() {
            merged.push(l[left_idx]);
            left_idx += 1;
            steps.push(self.step(StepAction::Merge(&merged)));
        }
        while right_idx < r.len() {
            merged.push(r[right_idx]);
            right_idx += 1;
            steps.push(self.step(StepAction::Merge(&merged)));
        }
        merged
    }
fn merge ( & self , l : & [ i64 ] , r : & [ i64 ] , steps : & mut Vec < serde_json :: Value > ) -> Vec < i64 > { let mut merged = Vec :: new ( ) ; let ( mut left_idx , mut right_idx ) = ( 0 , 0 ) ; while left_idx < l . len ( ) && right_idx < r . len ( ) { if l [ left_idx ] <= r [ right_idx ] { merged . push ( l [ left_idx ] ) ; left_idx += 1 ; } else { merged . push ( r [ right_idx ] ) ; right_idx += 1 ; } steps . push ( self . step ( StepAction :: Merge ( & merged ) ) ) ; } while left_idx < l . len ( ) { merged . push ( l [ left_idx ] ) ; left_idx += 1 ; steps . push ( self . step ( StepAction :: Merge ( & merged ) ) ) ; } while right_idx < r . len ( ) { merged . push ( r [ right_idx ] ) ; right_idx += 1 ; steps . push ( self . step ( StepAction :: Merge ( & merged ) ) ) ; } merged }
Perform the merging of the two lists for Merge Sort.
Perform the merging of the two lists for Merge Sort .
&self
l
&[i64]
r
&[i64]
steps
&mut Vec<serde_json::Value>