【leetcode】912. Sort an Array

题目如下:

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

 

Example 1:

Input: [5,2,3,1]
Output: [1,2,3,5]

Example 2:

Input: [5,1,1,2,0,0]
Output: [0,0,1,1,2,5]

 

Note:

  1. 1 <= A.length <= 10000
  2. -50000 <= A[i] <= 50000

解题思路:题目没说不能用系统函数。

代码如下:

class Solution(object):
    def sortArray(self, nums):
        """
        :type nums: List[int]
        :rtype: List[int]
        """
        return sorted(nums)
        

 

posted @ 2019-04-27 19:27  seyjs  阅读(312)  评论(0编辑  收藏  举报