c++

```
class Solution {
public:
int arrayPairSum(vector<int>& nums) {
sort(nums.begin(), nums.end());
int sum = 0;
for ( int i = 0; i < nums.size(); i += 2 ) {
sum += nums[i];
}
return sum;
}
};
```

python

```
class Solution(object):
def arrayPairSum(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
nums.sort()
return sum(nums[i] for i in xrange(0, len(nums), 2))
```