Sorting¶
Arrays¶
To sort an array use
To sort an array in descending order
this only works for non-primitive array i.e Integer [] array not int [] array
If we want to sort array from some index to some index use
If its a multi-dimensional array
to sort an array with custom comparator
CustomComparator implements Comparator<T> {
public int compare(T c1, T c2)
{
// return -1, 0, +1
}
}
List¶
To sort a list use