I have a dynamic PopupMenu defined as follow:

var = { PopupMenu[Dynamic[r3], 

px,px,tnare 3 numbers.

How can I random sort the order of the these elements, keeping the first always ""?

For example, I would like var to contain


one time, and another time


Furthermore, I would like the elements of the PopupMenu displayed in the following form: px,py,tn and not {px,py,tn}

  • $\begingroup$ Look up RandomSample[]. $\endgroup$ – J. M.'s discontentment May 29 '17 at 12:07
  • $\begingroup$ @Kuba I want to call it in different part of the notebook and "always" have a different result $\endgroup$ – Ale1794 May 29 '17 at 12:14
  • $\begingroup$ Like: var := {PopupMenu[ Dynamic[r3], {"", Sequence @@ RandomSample[{{py, px, tn}, {px, py, tn}, {-px, -py, tn}, {px, py, -tn}}]}]}? $\endgroup$ – Kuba May 29 '17 at 12:16
  • $\begingroup$ Let us continue this discussion in chat. $\endgroup$ – Kuba May 29 '17 at 13:05
var := PopupMenu[Dynamic[x],
       # -> Row[#, ","] & /@ RandomSample[
           {{py, px, tn}, {px, py, tn}, {-px, -py, tn}, {px, py, -tn}} 
    ,  ""

enter image description here

The code should be self explanatory but feel free to ask if anything is unclear.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.