Let's say I have posts in ordered list according to their date.
[<Post: 6>, <Post: 5>, <Post: 4>, <Post: 3>, <Post: 2>, <Post: 1>]
I want to break them into 3 groups, and shuffle the items inside the list accordingly.
chunks = [posts[x:x+2] for x in xrange(0, len(posts), 2)]
Now Chunks will return:
[[<Post: 6>, <Post: 5>], [<Post: 4>, <Post: 3>], [<Post: 2>, <Post: 1>]]
What are some efficient ways to randomly shuffle these items inside each respective lists? I could think of iterating through them, creating each respective lists but this seems repetitive...
I want the final output to look something like:
[[<Post: 5>, <Post: 6>], [<Post: 4>, <Post: 3>], [<Post: 1>, <Post: 2>]]
or better:
[<Post: 5>, <Post: 6>, <Post: 4>, <Post: 3>, <Post: 1>, <Post: 2>]