Gives desired output in local compiler but shows error in this case


I used sorting and then appending into a StringBuffer and then print accordingly in the local compiler the desired outut was received but then it says its wrong.
public void merge(ArrayList a, ArrayList b) {
StringBuffer sb=new StringBuffer();
for(int i=0;i<b.size();i++){
sb.append(" ");

For custom input 2 1 2
2 -1 2 it return s -1 1 2 2 in local compiler where as here it shows -4 3 don’ t know where I went wrong.