To sort the array or similae data structure we can use Comparator to sort the data how we want
Arrays.sort(intervals, new Comparator<int[]>(){
@Override
public int compare(int[] a,int[] b){
return Integer.compare(a[0],b[0]);
}
});