I am trying to sort each row of a 2d String array in java.
Example:
For example, if an array contains:
ZCD
BFE
DZA
I want it to be sorted as:
CDZ
BEF
ADZ
Code:
private String[] commonCollections;
private int comparisons = 0;
public Comparable[] findCommonElements(Comparable[][] collections){
for(int i = 0; i < collections.length; i++){
Arrays.sort(collections[i]);
}
for(int i = 0; i <collections[0].length; i++){
System.out.print(collections[0][i] + "\n");
}
return commonCollections;
}
Thanks. With the code above, its not sorting for some reason.