Sort an array when two halves are sorted | Java program to Merge two sorted halves of array Into Single Sorted Array ; Sort the given array using sort STL ; Driver code ; Print sorted Array
import java . io . * ; import java . util . * ; class GFG { static void mergeTwoHalf ( int [ ] A , int n ) { Arrays . sort ( A ) ; } static public void main ( String [ ] args ) { int [ ] A = { 2 , 3 , 8 , - 1 , 7 , 10 } ; int n = A . length ; mergeTwoHalf ( A , n ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( A [ i ] + " ▁ " ) ; } }