For sorting Arrays.sort(arr) is used, which is static function in arrays class.
Here a is array and method uses a tuned version of the QuickSort algorithm
int arr[] = {4,3,1};
Arrays.sort(arr);
This will sort the array in ascending order.
Seeing various sorting methods:
Method | Description |
| Sorts the elements of the array of a primitive type into ascending order using their natural ordering. |
| Sorts the elements pa[from]...pa[to-1] of a primitive type. into ascending order. |
| Sorts the elements of the array of an object type into ascending order, using the order defined by |
| Sorts the elements of the array, in the range from...to of an object type into ascending order. |
| Sorts the elements of the array of an object type into ascending order, using the Comparator comp. |
| Sorts the elements of the array, in the range from...to of an object type into ascending order using the Comparator comp. |
No comments:
Post a Comment