This function takes an array of arrays as an argument and all arrays are assumed to be sorted . It merges them together and prints the final sorted output .
function mergeKArrays ( arr , i , j , output ) {