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

Add a reverse method to Map

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.7.2, 1.8-beta-1
    • None
    • None

    Description

      It would be nice to be able to reverse the order of a map without running collect on it first. For example,

      def foo = ["string1":1, "string2":2, "string3":3]
      println foo.sort

      {it.value}.collect{it}.reverse() // <-- this works
      //println foo.sort {it.value}

      .reverse() // <-- this is what I propose

      This is, of course, a simplistic example for which there are workarounds, like
      foo.sort {-it.value}
      but I could imagine other potential uses for this method.

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              keegan Keegan Witt
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: