其他分享
首页 > 其他分享> > 905. 按奇偶排序数组

905. 按奇偶排序数组

作者:互联网

 

 

 

 

 

 

 1 class Solution(object):
 2     def sortArrayByParity(self, A):
 3         """
 4         :type A: List[int]
 5         :rtype: List[int]
 6         """
 7         # 根据元素是否为偶数排列
 8         return sorted(A, key=lambda num: num % 2 == 0, reverse=True)
 9 
10 if __name__ == '__main__':
11     solution = Solution()
12     print(solution.sortArrayByParity([6, 1, 2, 4]))

 

标签:__,奇偶,sortArrayByParity,905,int,List,Solution,num,排序
来源: https://www.cnblogs.com/panweiwei/p/12800265.html