About 167,000 results
Open links in new tab
  1. Sort an array in Java - Stack Overflow

    Aug 1, 2017 · For natural order : Arrays.sort(array) For reverse Order : Arrays.sort(array, Collections.reverseOrder());-- > It is a static method in Collections class which will further call …

  2. How to sort an array of objects in Java? - Stack Overflow

    One way is to use a standard sorting algorithm. Let's say you have an array of books and you want to sort them on their height, which is stored as an int and accessible through the method …

  3. java Arrays.sort 2d array - Stack Overflow

    Sort 2D Array in Java based by Row. 3. Sort a nxn matrix (2D Array) 0. 2D arrays sorting. 3. sort 2D array ...

  4. Java Array Sort descending? - Stack Overflow

    Nov 8, 2009 · It's not directly possible to reverse sort an array of primitives (i.e., int[] arr = {1, 2, 3};) using Arrays.sort() and Collections.reverseOrder() because those methods require …

  5. java - How to sort a List/ArrayList? - Stack Overflow

    Apr 27, 2013 · Collections.sort allows you to pass an instance of a Comparator which defines the sorting logic. So instead of sorting the list in natural order and then reversing it, one can simply …

  6. java: Arrays.sort() with lambda expression - Stack Overflow

    I want to sort String elements in the array months by length using Arrays.sort method. I was told here, that it's possible to use lambda expressions instead of creating new class implementing …

  7. json - How can I sort a JSONArray in JAVA - Stack Overflow

    Oct 23, 2013 · I know this works but it is terrible that we have to resort to something like this to reuse the sort function knowing that JsonArray contains the items as a collection private final …

  8. java - How to sort String array by length using Arrays.sort() - Stack ...

    Mar 8, 2016 · I am trying to sort an array of strings according to their length using Arrays.sort(), but this sorts the strings lexicographically rather than by length. Here is my code: S = "No one …

  9. Sort int array in descending order using java 8 features (stream ...

    Aug 3, 2015 · Surprisingly, it seems there was no simple, one-liner kind of solution in java to sort int array in descending order before java 8. For example, check this post. Now that we have …

  10. java - Random shuffling of an array - Stack Overflow

    Oct 5, 2009 · Java collections Arrays.asList takes var-arg of type T (T ...). If you pass a primitive array (int array), asList method will infer and generate a List<int[]>, which is a one element list …