- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to sort Short array
To sort Short array, use the Arrays.sort() method.
Let us first declare and initialize an unsorted Short array.
short[] arr = new short[] { 35, 25, 18, 45, 77, 21, 3 };
Now, let us short the array.
Arrays.sort(arr);
The following is the complete example that shows how to sort Short array in Java.
Example
import java.util.*; public class Demo { public static void main(String []args) { short[] arr = new short[] { 35, 25, 18, 45, 77, 21, 3 }; System.out.println("Unsorted:"); for (short s : arr) { System.out.println(s); } System.out.println("Sorted:"); Arrays.sort(arr); for (short s : arr) { System.out.println(s); } System.out.println(); } }
Output
Unsorted: 35 25 18 45 77 21 3 Sorted: 3 18 21 25 35 45 77
- Related Articles
- Java program to Sort long Array
- Java Program to fill elements in a short array
- Java Program to sort integers in unsorted array
- Java Program to sort a subset of array elements
- Java Program to sort an array in alphabetical order
- Java Program to compare Two Java short Arrays
- Java Program to sort an array in case-insensitive order
- Java Program to sort an array in case-sensitive order
- Java Program to Sort Array list in an Ascending Order
- Java Program to list Short Month Names
- Java Program to list Short Weekday Names
- Java Program to convert String to short primitive
- Golang Program To Sort An Array
- C program to sort an array by using merge sort
- Java program to implement bubble sort

Advertisements