Anyone have a way of reordering a list randomly?
Gotta love the new list functions
https://www.desmos.com/calculator/kkd2bkbjzt
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!
Turns out I completely forgot about another list function:
https://www.desmos.com/calculator/auphl9qezw
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
I know I’m late to the game, I wanted to thank you for asking the question as I’m trying to do the same thing. I’m trying to make a card shuffler.
With the new advanced feature, clickable actions, you can create a clickable polygon that runs D_0->shuffle(D_0) which will reshuffle D_0 from it’s latest shuffle.
My build looks more complicated than it is because the decimal points on the card values represent differences between 10, J, Q, K in the tenths place, Clubs, Diamonds, Hearts, Spades in the hundredths place, and Deck number in the thousandths place. The intention of coding the card type in the decimal is that I’ll later use round(D_0[p_0]) when calculating the value of a Blackjack hand.