# How do I disorder a list in Mathematica?

Given a list like this (the original list is much longer), how I can get a completely unordered list and save it in plain text?

I change the file names (names at random), using a length of 5 digits, but maintain the extension .jpg.

023.JPG
20150122_105236.jpg
20150122_105247.jpg
20150122_115905.jpg
20150122_141132.jpg
20150122_141248.jpg
20150122_141252.jpg
20150122_141259.jpg
20150122_141308.jpg
20150122_150834.jpg
20150122_150901.jpg
DSC00001.JPG
DSC00002.JPG
DSC00003.JPG
DSC00004.JPG
DSC00005.JPG
DSC00007.JPG
DSC00008.JPG
DSC00009.JPG
DSC00010.JPG
DSC00011.JPG
DSC00012.JPG
DSC00013.JPG
DSC00014.JPG
DSC00015.JPG
DSC00016.JPG
DSC00017.JPG
DSC00018.JPG
DSC00019.JPG
DSC00020.JPG
DSC00021.JPG
DSC00022.JPG
DSC00023.JPG
DSC00024.JPG
DSC00025.JPG
DSC00026.JPG
DSC00027.JPG
DSC00028.JPG
DSC00029.JPG
DSCI6714.JPG
DSCI6715.JPG
DSCI6716.JPG
DSCI6717.JPG
DSCI6718.JPG
DSCI6719.JPG
DSCI6720.JPG
DSCI6721.JPG
DSCI6722.JPG
DSCI6723.JPG
DSCI6724.JPG
DSCI6725.JPG
DSCI6726.JPG
DSCI6727.JPG
DSCI6728.JPG
DSCI6729.JPG
DSCI6730.AVI
DSCI7147.JPG
IMG_0877.JPG
IMG_0878.JPG
IMG_0879.JPG
IMG_0880.JPG
IMG_0881.JPG
IMG_0882.JPG
IMG_0883.JPG
IMG_0884.JPG
IMG_0885.JPG
IMG_0886.JPG
IMG_0887.JPG
IMG_0890.JPG

• Are you sure this is a list ? In what sense completely unordered ? Add some details and add a minimum (non)working example to illustrate what you are trying to do. Mar 7 '15 at 19:42
• Could be considered a duplicate of: (7926) Mar 7 '15 at 19:56
• You say that you maintain the extension .jpg, but (a) .JPG and .jpg are, actually, different names, and (b) one of those files is .AVI.
– TRiG
Mar 8 '15 at 2:41
• In my suggested edit, I left the word "disorder" in your title, because it might be helpful for other searchers using the same term. Generally, though, shuffle is the word used in programming (and in card games).
– TRiG
Mar 8 '15 at 2:43

To shuffle a list simply apply RandomSample:

RandomSample @ Range[9]

{3, 7, 1, 8, 4, 9, 6, 2, 5}


See Shuffling a list in Mathematica for other ideas.

how I can get a completely unordered list

lst = {"DSC00025.JPG",
"DSC00026.JPG", "DSC00027.JPG", "DSC00028.JPG", "DSC00029.JPG", "DSCI6714.JPG",
"DSCI6715.JPG",  "DSCI6716.JPG",  "DSCI6717.JPG",  "DSCI6718.JPG",  "DSCI6719.JPG",
"DSCI6720.JPG",  "DSCI6721.JPG",  "DSCI6722.JPG",  "DSCI6723.JPG",
"DSCI6724.JPG",  "DSCI6725.JPG","DSCI6726.JPG","DSCI6727.JPG","DSCI6728.JPG",
"DSCI6729.JPG","DSCI6730.AVI","DSCI7147.JPG", "IMG_0877.JPG", "IMG_0878.JPG",
"IMG_0879.JPG", "IMG_0880.JPG", "IMG_0881.JPG", "IMG_0882.JPG", "IMG_0883.JPG",
"IMG_0884.JPG", "IMG_0885.JPG", "IMG_0886.JPG", "IMG_0887.JPG", "IMG_0890.JPG"}

n = Length@lst;
idx = RandomSample[Range[n], n]
lst = lst[[idx]]

{"DSCI6715.JPG", "IMG_0879.JPG", "IMG_0886.JPG", "IMG_0882.JPG", "IMG_0877.JPG",
"DSCI6726.JPG", "DSCI7147.JPG", "DSC00027.JPG","DSCI6720.JPG", "DSCI6730.AVI",
"DSC00026.JPG", "DSCI6718.JPG", "DSCI6729.JPG", "IMG_0883.JPG", "DSCI6724.JPG",
"IMG_0887.JPG", "DSCI6727.JPG", "IMG_0884.JPG", "DSC00028.JPG", "DSC00025.JPG",
"DSCI6723.JPG", "IMG_0890.JPG", "IMG_0885.JPG", "DSCI6717.JPG",
"IMG_0881.JPG", "DSCI6728.JPG", "IMG_0878.JPG", "DSCI6721.JPG", "DSC00029.JPG",
"DSCI6719.JPG", "IMG_0880.JPG", "DSCI6722.JPG", "DSCI6725.JPG", "DSCI6714.JPG",
"DSCI6716.JPG"}


To save, look the command Export

• Simple RandomSample[lst] is enough - unless you specifically want to have the idx list. This works properly even when there are duplicates in lst. Mar 8 '15 at 6:08