Problem is i have 2 arrays `int input2[]={5,1,9,3,8};` and `int input3[]={2,0,3,6,1};`  

 have sorted array input2 using `Arrays.sort(input2);` now i want to place elements in array `inputs3` as per the new positions of elements of array `input2`

input array pre Sort- 5,1,9,3,8
input array post Sort - 1,3,5,8,9
now the elements of array input3 should also change as per the positions of array input2
preSort 2,0,3,6,1
Post sort 0,6,2,1,3

though i have written the code , but looking for an optimal solution`enter code here`

```
private static int[] swap(int[] arr, int i, int j,int [] arr2) {
    arr2[i]=arr[j];
    return arr2;
}

public static void main(String[] args) {
    int input2[]={5,1,9,3,8};
    int input3[]={2,0,3,6,1};
    int []temp=input2.clone();
    int []input4=input3.clone();
    Arrays.sort(input2);

    for(int i=0;i<=input2.length-1;i++){
        for(int j=0;j<=input2.length;j++){
            if(input2[i]==temp[j]){
                input4= swap(input3,i,j,input4);
                break;
            }  
        } 
    }        
}

```