Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8078076

Create Overload List#sort() for Natural Ordering Case

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 8u40
    • core-libs

      A DESCRIPTION OF THE REQUEST :
      Enhancement Proposal:

      With Java 8's API change, Collections#sort(List, Comparator) can now be rewritten as List#sort(Comparator), but Collections#sort(List), which sorts the list according to the elements' natural ordering, must be written this way as well, with "null" passed in as the comparator argument. This proposal suggests creating a zero-argument overload, List#sort(), for the latter case, so that a null literal does not have to be passed in for this common case.

      JUSTIFICATION :
      Sorting a list of elements by their natural order is a common case (perhaps the most common). Requiring the user to pass in a null argument for in this case seems unnatural.


            smarks Stuart Marks
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: