Berikut source code programnya, ane menggunakan kompiler Java Netbeans :
public class Merge_Sorting_TianChan {
public static void main(String a[])
{
System.out.println("SEPTIAN MAULANA");
System.out.println("1141177004039");
System.out.println("*** TianChan ***");
System.out.println();
System.out.println("Merge Sorting");
System.out.println();
//Nomor yang akan di urutkan
int n[] = {787,760,469,324,282,686,840,78,508,495,456,812,475,840,225,719,14,918,157,744,514,72,632,653,837,119,996,646,680,807,818,414,22,264,150,341,724,765,165,506,359,973,862,862,965,944,626,924,49,529,849,252,895,778,106,494,103,646,607,364,713,479,579,1,30,807,313,437,47,412,74,122,349,933,754,225,468,57,848,877,452,79,329,106,445,351,503,998,950,727,347,429,874,411,716,627,761,300,514,169,838,880,276,659,786,74,690,73,20,656,120,657,267,275,976,5,866,772,731,480,230,521,867,820,471,502,872,168,760,913,677,453,53,870,654,47,561,785,457,769,113,201,206,617,537,601,116,523,328,379,281,393,626,254,341,103,786,342,68,260,202,538,486,133,905,928,717,76,567,877,274,998,880,113,797,763,410,118,711,486,357,258,525,219,911,210,83,208,481,166,267,988,753,556,905,101,364,76,948,982,960,978,771,197,691,538,185,450,484,430,46,995,180,91,332,92,16,522,387,676,614,890,913,579,730,458,834,792,220,12,335,543,727,533,302,111,480,330,110,234,617,180,102,613,9,700,81,247,266,705,791,695,839,262,835,918,800,913,708,643,691,254,843,709,809,274,160,835,10,827,537,40,342,549,321,618,497,175,56,441,369,892,324,709,31,958,820,656,728,909,309,754,655,668,19,667,409,484,422,388,277,258,606,894,390,684,484,460,950,514,126,317,272,919,71,121,498,334,393,85,262,873,919,513,891,420,660,854,565,144,922,589,213,764,976,635,54,430,859,304,430,439,207,87,188,813,466,864,813,474,725,185,413,521,216,299,956,369,425,704,198,33,393,595,519,867,939,696,834,102,217,186,548,836,717,939,961,562,865,358,866,246,396,208,882,906,282,277,4,990,342,751,251,324,615,442,797,925,756,3,861,745,372,766,779,204,62,334,123,508,842,855,311,358,347,791,577,856,58,619,536,233,320,703,478,117,911,773,709,189,686,407,444,435,631,719,90,778,806,619,885,364,160,62,630,662,213,65,925,430,972,337,629,357,898,866,676,759,407,874,242,622,189,224,19,934,533,706,586,492,872,182,355,352,367,632,669,866,855,779,819,289,116,619,606,653,897,262,577,998,826,939,704,94,6,562,53,473,636,107,248,373,848,571,379,68,826,913,71,438,844,935,871,444,622,532,679,207,528,486,632,327,387,893,259,728,108,210,599,390,982,38,113,545,851,503,559,867,311,453,361,678,865,387,652,388,566,809,492,830,180,95,654,805,784,91,55,463,460,499,964,497,792,487,104,132,900,541,667,882,32,952,877,575,777,131,319,660,960,902,985,982,775,555,286,429,139,331,545,649,961,138,626,255,967,137,448,185,152,962,461,844,290,837,929,771,464,129,204,329,751,103,643,275,808,960,613,923,33,95,635,673,312,73,963,476,509,553,968,38,402,584,247,302,505,529,871,839,827,27,862,374,953,823,581,17,240,10,967,778,470,644,499,683,579,918,883,731,823,643,73,566,686,549,381,699,514,272,109,735,853,332,962,280,200,884,18,524,85,107,632,775,190,454,44,402,113,756,216,585,577,355,344,581,801,60,108,32,63,174,246,840,58,712,515,418,738,888,776,824,851,673,211,45,461,441,506,220,267,512,99,345,790,836,930,247,622,202,624,73,348,239,934,660,135,188,894,809,945,216,970,705,477,975,428,856,215,832,113,244,480,701,683,175,788,235,169,456,106,649,653,281,511,422,930,473,319,899,63,561,586,679,269,115,455,121,185,702,72,48,886,166,97,39,226,137,670,908,523,876,624,47,726,820,339,736,788,385,431,121,18,741,305,795,515,834,478,220,268,752,299,541,843,38,260,898,269,176,759,563,947,831,332,168,736,967,652,505,290,226,522,395,962,873,138,14,394,498,509,755,858,381,70,571,238,320,652,451,336,107,813,628,813,94,579,494,487,974,5,188,39,262,549,715,988,978,273,925,276,967,104,834,278,174,131,238,434,544,726,69,814,588,610,442,573,635,344,295,166,380,892,303,623,43,3,431,619,716,122,244,55,733,548,838,949,834,408,337,923,26,965,468,428,223,251,970,432,627,720,414,634,317,331,500,398,771,920,555,901,594,696,406,46,800,421,697,403,563,143,937,285,714,974,700,477,945,724,504,889,530,14,88,110,966,831,560,384,452,441,73,67,576,649,80,805,901,813,337,571,933,325,18,285,28,788,538,614,989,513,368,811,484,62,999,736,115,332,375,305,568,801,383,412,532,912,630,793,54,907,226};
System.out.println("Sebelum di Urutkan = ");
for(int i = 0; i < n.length; i++)
{
System.out.print(n[i]+" ");
}
System.out.println();
initializemergeSort(n,0,n.length-1);
System.out.println();
System.out.println("Setelah di Urutkan = ");
for(int i = 0; i < n.length; i++)
{
System.out.print(n[i]+" ");
}
}
public static void initializemergeSort(int n[], int l, int h)
{
int low = l;
int high = h;
if (low>=high)
{
return;
}
int middle=(low+high)/2;
initializemergeSort(n,low,middle);
initializemergeSort(n,middle+1,high);
int end_low=middle;
int start_high=middle+1;
while ((l<=end_low) && (start_high<=high))
{
if (n[low]<n[start_high])
{
low++;
}
else
{
int Temp=n[start_high];
for (int k=start_high-1;k>=low;k--)
{
n[k+1]=n[k];
}
n[low]=Temp;
low++;
end_low++;
start_high++;
}
}
}
}
Berikut hasil output program :