Problem

Given an array of integers nums, sort the array in ascending order.

You must solve the problem without using any built-in functions in O(nlog(n)) time complexity and with the smallest space complexity possible.

Examples

Input: Array of numbers , unsorted. Eg.

Output : Same numbers sorted in some order, say increasing order. Eg.

Input:
nums = [7, 4, 6, 1, 3, 5, 8, 2]
Output:
 [1, 2, 3, 4, 5, 6, 7, 8]

Solution

There are multiple solutions to this. Here are some:

Integer Specific

Sorting an Object

Java

Java Sorting Collections Index

Time Complexity

Sorting Algorithms Time Complexity Comparison