Why a Groovy script keeps the previous array value?
<p>I have this simple Groovy script (executed from SoapUI):</p>

<pre><code>def String[] unsorted
def String[] sorted

unsorted=null
sorted=null

unsorted = ["Lucas", "Fred", "Mary", "Aaron", "Brent"]
log.info("unsorted: ${unsorted}")

sorted = unsorted.sort()
log.info("sorted: ${sorted}")
</code></pre>

<p>When I execute it the first time, it sorts the unsorted array as expected. However the second time that I run it, the unsorted array is displayed with the sorted values. Even if I reset both arrays to null at the beggining, it keeps the results from the sorted array. Does somebody have an idea why?</p>

<p>This is the output:</p>

<p><a href="https://i.stack.imgur.com/1x9sa.png" rel="nofollow noreferrer">Log Output View</a>
<a href="https://i.stack.imgur.com/1x9sa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1x9sa.png" alt="enter image description here"></a></p>