title: List in place sorting in Jenkins Pipelines
body: <p>I am trying to sort a list of objects in Jenkins pipelines. I'm getting different results running code below locally or within Jenkins:</p>
  
  <pre><code>pipeline {
      agent any
      stages {
          stage('default'){
              steps {
                  script {
                     @NonCPS
                     def nonCpsTest = {
                          def list = [
                              ['CreationDate': '200'],
                              ['CreationDate': '300'],
                              ['CreationDate': '100'],
                         ]
  
                         def rval = list.sort { it['CreationDate'] }
  
                         echo "Rval=$rval"
                         echo "List=$list"  
                     }
                     nonCpsTest()
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>When I execute this script locally using groovy shell (<code>groovysh</code>) result is</p>
  
  <pre><code>groovy:000&gt; list = [[ 'CreationDate':200 ], [ 'CreationDate':300 ], [ 'CreationDate':100 ]]
  ===&gt; [[CreationDate:200], [CreationDate:300], [CreationDate:100]]
  groovy:000&gt;  rval = list.sort { it['CreationDate'] }
  ===&gt; [[CreationDate:100], [CreationDate:200], [CreationDate:300]]
  groovy:000&gt; list
  ===&gt; [[CreationDate:100], [CreationDate:200], [CreationDate:300]]
  groovy:000&gt; list == rval
  ===&gt; true
  </code></pre>
  
  <p>While on the Jenkins server I'm getting following</p>
  
  <pre><code>[Pipeline] {
  [Pipeline] stage
  [Pipeline] { (default)
  [Pipeline] script
  [Pipeline] {
  [Pipeline] echo
  Rval=300
  [Pipeline] echo
  List=[[CreationDate:200], [CreationDate:300], [CreationDate:100]]
  [Pipeline] }
  [Pipeline] // script
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  </code></pre>
  
  <p>Is Jenkins workflow making list immutable in anyway, or overriding <code>sort</code> method, and if so, how to do in place list sorting within the Jenkins pipeline code?</p>