Practice
Resources
Contests
Online IDE
New
Free Mock
Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
Scaler
Explore Offerings by SCALER

Go to Problems

# Sort Implementation Details

##### C :
###### sorting integer array A with size sz,
``````    // You will have to implement a compareFunction. Example shown below.
qsort(A, sz, sizeof(int), compareFunction);

// Example of compare function
int compareFunction(const void* a, const void* b) {
int value1 = *((int *)a);
int value2 = *((int *)b);
if (value1 < value2) {
// Return -1 if you want ascending. 1 if you want descending.
return -1;
} else if (value1 > value2) {
// Return 1 if you want ascending. -1 if you want descending.
return 1;
}
return 0;
}
``````
##### C++
###### Sorting vector V,
``````    sort(V.begin(), V.end());
``````
##### JAVA
``````    ArrayList<Integer> A = ....
Collections.sort(A);
``````
##### PYTHON :
``````    l = [...]
l.sort()
``````

## Serious about Learning Programming ?

Learn this and a lot more with Scaler Academy's industry vetted curriculum which covers Data Structures & Algorithms in depth.
Primers
Examples

## Arrays Problems

Array math
Value ranges
Problem Score Companies Time Status
Max Min 150
17:31
Merge Intervals 225 78:57
Merge Overlapping Intervals 225 48:24
Simulation array
Problem Score Companies Time Status
Perfect Peak of Array 200 49:07
Move Zeroes 200 26:13
Make equal elements Array 200 31:37
Segregate 0s and 1s in an array 200 15:01
Array Sum 200 32:57
Kth Row of Pascal's Triangle 225
28:32
Spiral Order Matrix II 225 48:40
Pascal Triangle 225 26:46
Anti Diagonals 225 41:46
Bucketing
Problem Score Companies Time Status
Triplets with Sum between given range 200
76:10
Balance Array 200 62:01
Find Duplicate in Array 450 40:13
Maximum Consecutive Gap 450 58:46
Arrangement
Problem Score Companies Time Status
Sort array with squares! 200 31:21
Largest Number 225 70:26
Rotate Matrix 300 60:26
Next Permutation 300 63:13
Find Permutation 300 56:00
Hash search
Problem Score Companies Time Status
Occurence of Each Number 200 24:41
Sorting
Problem Score Companies Time Status
Noble Integer 200 43:30
Reorder Data in Log Files 200 42:17
Set Intersection 200 62:14
Wave Array 225 22:08
Hotel Bookings Possible 225 66:06
Max Distance 250 68:14
Maximum Unsorted Subarray 250 68:52
Space recycle
Problem Score Companies Time Status
Set Matrix Zeros 300 48:04
First Missing Integer 300 64:38
Maximum Sum Square SubMatrix 300 57:02
Missing / repeated number
Problem Score Companies Time Status
First Missing Integer 300 64:38
Repeat and Missing Number Array 350 63:55
N/3 Repeat Number 600
68:22

Problem Score Companies Time Status
Greater of Lesser 200 13:15
Spiral Matrix 200 30:44
Product of All 200 29:49
Chips Factory 200 19:06
Greater than All 150 18:47
Pythagorean Triplets 200 24:25
Diagonal Flip 200 18:11
Positive Negative 100 10:00
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Select an option *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
*Enter the expected year of graduation if you're student
Current Employer *
Company Name *
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.