Sorting of an array of numbers

- If an array containing number is sorted using sort function it takes every value in the array as a string so 12 will be placed before 2.
- Therefore, to consider the values as a number, spaceship operator() is used instead of cmp in the sort function.
- This operator considers its operands as a number and sorts the data as a number.
No comments