
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Sort an Array of Integers
								Certification: Basic Level
								Accuracy: 73.68%
								Submissions: 19
								Points: 5
							
							Write a C++ function to sort an array of integers in ascending order.
Example 1
- Input: array = [5, 3, 8, 1]
 - Output: [1, 3, 5, 8]
 - Explanation:
    
- Step 1: Compare and swap elements to sort them in ascending order.
 - Step 2: Rearrange the array through multiple passes.
 - Step 3: Return the sorted array.
 
 
Example 2
- Input: array = [10, 2, 7, 4]
 - Output: [2, 4, 7, 10]
 - Explanation:
    
- Step 1: Compare and swap elements to sort them in ascending order.
 - Step 2: Rearrange the array through multiple passes.
 - Step 3: Return the sorted array [2, 4, 7, 10].
 
 
Constraints
- 1 ≤ array length ≤ 10^4
 - -10^5 ≤ array elements ≤ 10^5
 - Time Complexity: O(n log n)
 - Space Complexity: O(1)
 
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Use a sorting algorithm like quicksort or mergesort.
 - You can also use the built-in 
sortfunction from the C++ STL. - Ensure the function works for the upper limit of the constraint.