package ru.job4j;

/**.
*
* @author Anton Vasilyuk
* @version 1.0
* @since 0.1
*/

public class SortMyNumber {
	/**.
	* Method for sort Two array
	* @param first array
	* @param second array
	* @return result sorting
	*/
	public int[] sortMyArrays(int[] first, int[] second) {
		int val;
		int[] a;
		int[] b;
		int[] readyArray = new int[first.length + second.length];
		if (first.length >= second.length) {
			a = first;
			b = second;
		} else {
			a = second;
			b = first;
		}
        for (int j = readyArray.length - 1, i = 0; j >= 0; j--, i++) {
            if (i < b.length) {
                readyArray[j] = a[i];
                readyArray[j - 1] = b[i];
                for (int x = 0; x < readyArray.length; x++) {
                    for (int y = readyArray.length - 1; y > x; y--) {
                        if (readyArray[y] < readyArray[y - 1]) {
                            val = readyArray[y];
                            readyArray[y] = readyArray[y - 1];
                            readyArray[y - 1] = val;
                        }
                    }
                }
                j--;
            } else {
                readyArray[j] = a[i];
                for (int x = 0; x < readyArray.length; x++) {
                    for (int y = readyArray.length - 1; y > x; y--) {
                        if (readyArray[y] < readyArray[y - 1]) {
                            val = readyArray[y];
                            readyArray[y] = readyArray[y - 1];
                            readyArray[y - 1] = val;
                        }
                    }
                }
            }
        }
        return readyArray;
    }
}
@@ -280,33 +280,26 @@
 int 
-val;%0A%09%09int%5B%5D a
+i = 0
 ;%0A%09%09int
-%5B%5D b
+ j = 0
 ;%0A%09%09
@@ -358,20 +358,27 @@
 gth%5D;%0A%09%09
-if (
+while (i %3C 
 first.le
@@ -382,18 +382,22 @@
 .length 
-%3E=
+%7C%7C j %3C
  second.
@@ -413,1219 +413,253 @@
 %0A%09%09%09
-a = first;%0A%09%09%09b = second;%0A%09%09%7D else %7B%0A%09%09%09a = second;%0A%09%09%09b = first;%0A%09%09%7D%0A        for (int j = readyArray.length - 1, i = 0; j %3E= 0; j--, i++) %7B%0A            if (i %3C b.length) %7B%0A                readyArray%5Bj%5D = a%5Bi%5D;%0A                readyArray%5Bj - 1%5D = b%5Bi%5D;%0A                for (int x = 0; x %3C readyArray.length; x++) %7B%0A                    for (int y = readyArray.length - 1; y %3E x; y--) %7B%0A                        if (readyArray%5By%5D %3C readyArray%5By - 1%5D) %7B%0A                            val = readyArray%5By%5D;%0A                            readyArray%5By%5D = readyArray%5By - 1%5D;%0A                            readyArray%5By - 1%5D = val;%0A                        %7D%0A                    %7D%0A                %7D%0A                j--;%0A            %7D else %7B%0A                readyArray%5Bj%5D = a%5Bi%5D;%0A                for (int x = 0; x %3C readyArray.length; x++) %7B%0A                    for (int y = readyArray.length - 1; y %3E x; y--) %7B%0A                        if (readyArray%5By%5D %3C readyArray%5By - 1%5D) %7B%0A                            val = readyArray%5By%5D;%0A                            readyArray%5By%5D = readyArray%5By - 1%5D;%0A                            readyArray%5By - 1%5D = val;%0A                        %7D%0A                    %7D%0A                %7D%0A            %7D%0A        
+if (i %3C first.length && j %3C second.length) %7B%0A%09%09%09%09readyArray%5Bi + j%5D = first%5Bi%5D %3C second%5Bj%5D ? first%5Bi++%5D : second%5Bj++%5D;%0A%09%09%09%7D else if (i == first.length) %7B%0A%09%09%09%09readyArray%5Bi + j%5D = second%5Bj++%5D;%0A%09%09%09%7D else %7B%0A%09%09%09%09readyArray%5Bi + j%5D = first%5Bi++%5D;%0A%09%09%09%7D%0A%09%09
 %7D%0A  

add file for chapter_001_Test