Challenge 2: Sorting an Array

In this challenge, you will figure out how to sort an Integer Array.

Problem statement

Implement a method in Java called sortAsc() which will sort an array of any size having integer values in an ascending order and return the sorted array in the output.

Note: The array does not need to be returned, we are doing it for ease of testing

Function prototype

int[] sortAsc(int[] arr)

Sample input

arr = {5,8,2,6,9}

Sample output

arr = {2,5,6,8,9}

Pictorial representation

Get hands-on with 1200+ tech skills courses.