1 class Solution(object): 2 def arrayPairSum(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 """ 7 nums.sort() 8 ans = 0 9 for i in range(0, len(nums), 2): 10 ans += nums[i] 11 return ans 12 13 14 if __name__ == '__main__': 15 solution = Solution() 16 print(solution.arrayPairSum([1, 4, 3, 2]))