Randomized list

Anyone have a way of reordering a list randomly?

1 Like

Gotta love the new list functions


I didn’t know that sort takes a second argument! Is that documented somewhere?

New CL functions were noted in the api changelog

and in these three articles:

Though, this extension of the sort function is not detailed.

Yes the details are what I want to see documented!

1 Like

Turns out I completely forgot about another list function:

Much simpler, and as @aknauft pointed out to me, avoids the chance that two random numbers are the same.


Is there I way I could go from the Lordered here back to L? (ie, if I have a random list of numbers but I want to sort them lowest to highest?)

Not sure I understand the question. If you’re responding to the post immediately before yours, each list is there to use in the graph. You can use L or L_shuffle as you see fit. They don’t overwrite each other.

Thanks, Daniel - I figured it out; you actually can just do sort(L) to get a list in ascending order, which is what I was looking for. Perhaps that is new from the posts in this thread, which seemed to imply that you needed a 2nd term in the sort(L,?) syntax. Apparently that 2nd term is optional.

There’s no second parameter for sort, but there can be for shuffle( ) or random( ). You can have a “seed” so when the second parameter changes a new list is generated. Easiest to use a variable for this situation.

Another function you may find use for in the future is unique( ), which basically eliminates any duplicates from a list.

You can actually sort one list according to another: Untitled Graph

But there’s also this other method: Untitled Graph