package MyPackage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class CoreUtils {
static List addLst = new ArrayList();
public static void main(String[] args) {
String[] dataSet1 = { "Sam,sam@gmail.com","AAA" };
String[] dataSet2 = { "Jenny,thomson,jenny@gmail.com","XXXX" };
String[] dataSet3 = { "tom,Hanks,tom.hanks@gmail.com","GGGG" };
addToList(dataSet1);
addToList(dataSet2);
addToList(dataSet3);
/** Sorting Based upon the First String in the String Array
*
*/
Collections.sort(addLst, new Comparator() {
@Override
public int compare(String[] o1, String[] o2) {
return o1[0].compareToIgnoreCase(o2[0]);
}
});
for (String[] array : addLst) {
for (String element : array)
System.out.print(element + ",");
System.out.println();
}
}
public static void addToList(String[] toBeAdded){
addLst.add(toBeAdded);
}
}