This solution includes both the sorting and hash table methods, and it's smart enough to distinguish when to use which method to maximize efficiency. For some reason, I still get a really slow time in the OJ though. I'd appreciate any insight as to why!

```
class Solution(object):
def arrayPairSum(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums) <= 5363:
# In this case, the O(len(nums) log(len(nums))) solution is faster, given a potential 20001 value spread
nums.sort()
sum = 0
for i in range(len(nums)):
if i % 2 == 0:
sum += nums[i]
return sum
else:
# In this case, the O(d) hash table solution is faster, given a potential 20001 value spread (i.e. d)
nums_hash = {}
for i in range(-10000, 10001):
nums_hash[i] = 0
for num in nums:
nums_hash[num] += 1
count = 0
sum = 0
for i in range(-10000, 10001):
while nums_hash[i] != 0:
if count % 2 == 0:
sum += i
nums_hash[i] -= 1
count += 1
if count == len(nums):
return sum
```