swift - 递增递减排序数组

light-ios

2018-04-30T06:55:36Z||2018-04-30T06:55:36Z

var nums = [4, 9, 3, 2, 4, 7, 6, 10, 1]

nums.sort(by: <)
print(nums)

nums.sort(by: >)
print(nums)

输出:

[1, 2, 3, 4, 4, 6, 7, 9, 10]
[10, 9, 7, 6, 4, 4, 3, 2, 1]