Pergunta

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());

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top