Skip to content

Commit

Permalink
Sorts array in ascending order
Browse files Browse the repository at this point in the history
1st exercise - leetcode.com/problems/sort-an-array/
  • Loading branch information
CharlesCreativeContent authored Jun 29, 2020
1 parent 5a10f45 commit 30c673a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Medium/sortAscending.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Given an array of integers nums, sort the array in ascending order.
Example 1:
Input: nums = [5,2,3,1]
Output: [1,2,3,5]
Example 2:
Input: nums = [5,1,1,2,0,0]
Output: [0,0,1,1,2,5]
*/

//Answer//

/**
* @param {number[]} nums
* @return {number[]}
*/
var sortArray = function(nums) {
return nums.sort((a,b)=>a-b)
};

0 comments on commit 30c673a

Please sign in to comment.