Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is there a straightforward way to go from an ordered list like:

ord = {a, b, c, d, e, f, g, h}

to a disordered list like:

randompos = {c, h, d, g, a, b, f, e}

I can certainly use something like:

DeleteDuplicates @ RandomChoice[ord, 50]

but this is not really robust.

Is there an easier way?

share|improve this question
Use RandomSample. – Spawn1701D Jun 25 '13 at 3:44
@Spawn1701D RandomSample won't be able to create the letter i out of thin air. The OP needs a god – belisarius has settled Jun 25 '13 at 3:46
@Spawn1701D That is a simplistic way :) – belisarius has settled Jun 25 '13 at 3:48
@belisarius typo fixed. i have no need for the divine. – geordie Jun 25 '13 at 4:09
RandomSample[#,Length[#]]&@ord – HyperGroups Jun 25 '13 at 4:13

1 Answer 1

up vote 9 down vote accepted

Method1 RandomSample

as @Spawn1701D and @Oleksandr R.said in comment,

RandomSample[ord] is sufficient.

ord = {a, b, c, d, e, f, g, h};



To get one sublist

RandomSample[#, Length[#] - 4] & @ ord


Method2 RandomPermutation

SeedRandom[1234]; Permute[ord, RandomPermutation[8]]


One aside: sometimes when people's comments are apparently feasible to the question, they might not likely to answer the post, others may wish the first people who leave the good comment to answer the question, and OP is also encouraged to answer its own question.

So I answer the little post with one additional method.

share|improve this answer
@HyperGoups -- no need to apologize. If the commenter wanted to answer, he would have spawned one by now. – bill s Jun 26 '13 at 5:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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