public class Solution {
public int arrayPairSum(int[] nums) {
Arrays.sort(nums);
int sum =0;
for (int i = 0; i < nums.length; i += 2) {
if (nums[i] > nums[i + 1]) {
sum += nums[i + 1];
} else {
sum += nums[i];
}
}
return sum;
}
}
```
class Solution:
def arrayPairSum(self, nums) -> int:
nums.sort()
s = 0
for i in range(0,len(nums),2):
s +=min(nums[i],nums[i+1])
return s