Shuffling Script

28 Apr '15, 04:38 PM
7,535 Views
No Forum Badges

Hi,
I need to randomize the order of a returned list from a database selecter. The best option for this seemsed to write a simple script. The passing of variables is ok, but my script doenst sort the list for some reason. Hope anyone can see my mistake or propose a other sollution.
 

#input Integer[] list
#output Integer[] mixedList

import java.util.*;
import java.util.Collections;
import java.util.Arrays;

Collections.shuffle(Arrays.asList(list))
return ["mixedList": list]

This work in normal java so should be no problem for groovy but my experience is limited with the groovy language.

 

 

 

 

 
x 0
Follow
Answer Answer at this question and get points!
No Forum Badges

I found the answer. The script is indeed correct. The problem is the list sorts automatic based on the only field present to it will always be sorted, deminishing the effects of my script.

 
x 0
Answer at this question and get points!