When you say "String[] b=a;" you aren´t copying the contents of a to b, you are pointing b to the same memory allocation than a, instead. Thus when you sort the array stored there you change both a and b... Use arrayCopy() instead: http://processing.org/reference/arrayCopy_.html Regards!