void mergSort(int num[], int temp[], int array)
{
    m_sort(num,temp,0,array - 1);
}
void m_sort(int num[], int temp, int left, int right)
{
    int center;
    if(right>left)
    {
        center=(right+left)/2;
        m_sort(num,temp,left,center);
        m_sort(num,temp,center+1,right);
        merge(num,temp,left,center+1,right);
    }
}
void merge(int num[], int temp[], int left, int center, int right){
    int i,left_end,num_elements,tmp_pos;
    left_end=center-1;
    tmp_pos=left;
    num_elements=right-left+1;

    while((left<=left_end)&&(center<=right))
    {
        if(num[left]<=num[center])
        {
        temp[tmp_pos]=num[left];
        tmp_pos=tmp_pos+1;
        left=left+1;
        }
    
    else
    {
        temp[tmp_pos]=num[center];
        tmp_pos=tmp_pos+1;
        center=center+1;
    }
}
while(left<=left_end)
{
    temp[tmp_pos]=num[left];
    left=left+1;
    tmp_pos=tmp_pos+1;
}
while(center<=right)
{
    temp[tmp_pos]=num[center];
    center=center+1;
    tmp_pos=tmp_pos+1;
}
for(i=0;i<=num_elements;i++){
    num[right]=temp[right];
    right=right-1;
}
}
