title: Java concatenate two arrays into one and sort it
body: <p>My task is to concatenate two arrays into one and sort it. I have already concatenated arrays, but can't sort it. 
  <br>My idea: Create a new array. In concatenated array through the loop, find the smallest element, push it to a new array and in the end, make it the largest number. However, this approach doesn't work.
  <br>
  My Code:</p>
  
  <pre><code>public class Concat_arrays {
  public static void main(String[] args) {
      int[] a1 = {4, 5, 3, 2, 1};
      int[] a2 = {10, 29, 0};
      int[] a3 = new int[a2.length+a1.length];
  
      int index = 0;
      for (int i = index; i&lt;a1.length; i++) {
          a3[i] = a1[i];
          index++;
      }
  
      int indexA2 = 0;
      while (indexA2&lt;a2.length) {
          a3[index] = a2[indexA2];
          index++;
          indexA2++;
      }
  
      int[] a4 = new int[a3.length];
  
      for (int i = 0; i&lt;a3.length; i++) {
          int min_index = getMin(a3);
          a4[i] = a3[min_index];
          a3[min_index] = 999999;
      }
  
  
  
  
  }
  
  public static int getMin(int[] array) {
      int min_element = 0;
      int min_element_index = 0;
  
      for (int i = 0; i&lt;array.length; i++) {
          if (min_element&gt;=array[i]) {
              min_element_index = i;
          }
      }
      return min_element_index;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>4
  999999
  999999
  999999
  999999
  999999
  999999
  999999
  </code></pre>