Sorting algorithm (modified merge sort)
#define MaxSize 7000
Algorithm (A [ ] [ ] , left, right, M, inter)
//A is array of MaxSize elements, which need to be sorted from left to right position, M // is the number of processors, which
will sort elements of array in parallel, inter is degree // of interleaving.
factor = ( r i g h t l e f t + 1 )/Pow (M, inter);
IF (factor > 3) THEN
  //This loop partitions the elements into M processors
  FOR ( 𝑖 = 0 to M DO)
          Sort Individual elements in the partitioned array with
          starting position as 𝐼 and end position till factor or
           f a c t o r + 1 , each element placed with “inter” positions
          next to previous elements.
  Merge (A, left, right, M, inter);
ELSE
  InsertionSort (A, left, n, right, Pow (M, i n t e r 1 ));
END
Algorithm of insertion sort is modified so that each element is placed with “inter” positions next to previous element
int j, p, Tmp, count;
FOR ( 𝑃 = 𝑖 + i n t e r , c o u n t = 1 ; count < 𝑁 , 𝑃 <= right; 𝑃 = 𝑃 + i n t e r , ++count)
  Tmp = 𝐴 [ 𝑃 ] ;
FOR ( 𝑗 = 𝑃 ; 𝑗 >= 𝐼 && 𝑗 i n t e r >= 𝑖 && 𝐴 [ 𝑗 i n t e r ]>Tmp; 𝑗 = 𝑗 i n t e r )
   𝐴 [ 𝑗 ] = 𝐴 [ 𝑗 i n t e r ];
𝐴 [ 𝑗 ] = T e m p ;
Modified Merge Algorithm
Algorithm Merge ( 𝐴 , left, right, 𝑀 , inter)
{
 pInter = Pow( 𝑀 , inter);
 FOR ( 𝑖 = 0 ; 𝑖 < 𝑀 ; 𝑖 ++) pointer [ 𝑖 ] = left + r*pInter/M;
   𝑁 = ( r i g h t l e f t + 1 );
 FOR 𝑖 = 0 to 𝑛 do
    FOR ( 𝑗 = 0 ; 𝑗 < 𝑀 ; + + 𝑗 )
      IF((pointer[ 𝑗 ] ! = 1 ) && (TmpArray[ 𝑖 ]> 𝐴 [pointer[ 𝑗 ]))
       TmpArray[ 𝑖 ] = A[pointer[ 𝑗 ];
       indexJ = 𝑗 ;
      IF(pointer[index 𝐽 ] + pInter > 𝑛 1 )
       pointer[index 𝐽 ] = −1;
      ELSE pointer[index 𝐽 ] + = p I n t e r ;
 END For( 𝑖 )
  FOR( 𝑖 = 0 ; 𝑖 < 𝑛 ; + + 𝑖 )
    𝐴 [ 𝑖 ] = TmpArray[ 𝑖 ];
}
Algorithm 1: Modified algorithms.