The sort() method is represented by the following syntax:
compareFunction - It is optional. It represents a function that provides an alternative sort order.
An array of sorted elements
Here, we will understand sort() method through various examples.
Let's see a simple example to sort the array of string elements.Test it Now
Let's see a simple example to sort the array of integer elements.Test it Now
Let's see an example to arrange the elements in ascending order using function.Test it Now
Let's see an example to arrange the elements in descending order using function.Test it Now
Let's see an example to extract minimum value from an array.Test it Now
Let's see an example to extract maximum value from an array.Test it Now
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week