My goal is to convert this Arrays.sort(nums, j+1, nums.length) into a reverse sort. The only reverse sort information I can find doesn't seem to have the ability to sort a subarray.

And this gives me an error Arrays.sort(nums, j+1, nums.length, Collections.reverseOrder());

有帮助吗?

解决方案

Since the Collections.reverseOrder() method only works for reference type, my suggestion is that your "nums" should hold reference type such as Integer, Double ... Or if you defined your own class, make sure your class implemented the Comparable interface

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top