Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3561

Documentation for the sort method in Collection class is misleading

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.6.1
    • 1.6.4, 1.7-beta-1
    • groovy-jdk
    • None
    • N/A

    Description

      The documentation for the sort method in Collection says that if this method is called with a closure, the closure must return the result of comparison. However, I think this text is applicable when the closure has 2 parameters. When the closure is used with 1 parameter in the closure, the closure must return a Comparable object.

      Link to documentation: http://groovy.codehaus.org/groovy-jdk/java/util/Collection.html#sort(groovy.lang.Closure closure)

      Also it would help if the documentation includes the fact that the closure can take either one or two parameters (and the expected behavior in both cases).

      Thanks.

      Attachments

        Activity

          People

            paulk Paul King
            adaptives Parag Shah
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: