1

I have an array called look. It contains 10 items in it. How do i sort index 7 to 9 in the array in descending order? below is code i use sort index 0 to 6 in ascending.

Arrays.sort(look, 0, 6);
3
  • So coming to arrays, have you check on any sorting methods? Commented Dec 8, 2012 at 14:00
  • yeah. i saw collections.reverseorder. but it seems it doesn't allow to specify the index number to sort. Commented Dec 8, 2012 at 14:02
  • Thanks. I changed my look from int to Integer. Commented Dec 8, 2012 at 14:12

2 Answers 2

2

Arrays.sort(look, 7, 9, Collections.reverseOrder());

should work.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use the Arrays method:

public static <T> void sort(T[] a, int fromIndex, int toIndex, Comparator<? super T> c)

With help of the Comparator interface you can define you own sorting mechanism.

see: public static void sort(T[] a, int fromIndex, int toIndex, Comparator c)) and Comparator

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.