About 51 results
Open links in new tab
  1. java - How to sort a List/ArrayList? - Stack Overflow

    Apr 27, 2013 · I have a List of Double objects in Java. I want to sort the ArrayList in descending order. Input ArrayList:

  2. java - ArrayList.sort () Method - Stack Overflow

    Jan 31, 2018 · The ArrayList.sort method does take a comparator which can be used to specify the sorting criteria, but as mentioned on the , passing it a null comparator is also valid: And as you can …

  3. sorting - How to sort an ArrayList in Java - Stack Overflow

    Aug 26, 2013 · How would your approach look like if I wanted to add multiple different sort options, for example Override the compareTo method to order by the object name, but add another one for …

  4. Sorting ArrayList with Lambda in Java 8 - Stack Overflow

    May 16, 2014 · Could somebody show me a quick example how to sort an ArrayList alphabetically in Java 8 using the new lambda syntax.

  5. java - Sorting an ArrayList of objects using a custom sorting order ...

    May 6, 2015 · I am looking to implement a sort feature for my address book application. I want to sort an ArrayList<Contact> contactArray. Contact is a class which contains four fields: name, home …

  6. What is the time complexity of Collections#sort method in Java?

    For Java 6, it's a modified version of mergesort. Check the description here: Collections#sort for Java 6 The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in …

  7. Sort ArrayList of custom Objects by property - Stack Overflow

    May 7, 2010 · 1295 I read about sorting ArrayLists using a Comparator but in all of the examples people used compareTo which according to some research is a method for Strings. I wanted to sort an …

  8. How to sort List of objects by some property - Stack Overflow

    Using Comparable (natural ordering): If sort algorithm always stick to one property: write a class that implements 'Comparable' and override 'compareTo' method as defined below

  9. Java, how to use compareTo to sort an Arraylist - Stack Overflow

    You're only honoring the contract that you need to establish for Collections.sort() to work properly. It's actually Collections.sort() that makes use of your compareTo method, since it only sorts things that …

  10. How to do sorting in array list without using collections in Java

    Jul 13, 2015 · Is there a way to do it without using set method? No. Unless you wish to convert your ArrayList to an array, sort the array, and update the ArrayList with the sorted array.