The code doesn't seem to be working for me though when I tried it, any reason why that would be? I've attached an image of how the code looks when I put it into the question editor.
!
I should have specified that I was originally using the 'matrix' drag and drop question format not the 'pick, group and rank' one, so I had a bit of trouble getting the code to work for a while. As soon as I changed it to the pick, group and rank question though, it worked!
This was really helpful, I've not really done any coding before so this is all very new to me! Thanks!