Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
shuffling elements of a list
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Iain King, post: 1883232"] or in nicer python, but still when you're mysitified by map and lambda (like me): def shuffle(data): decorated = [(random(), x) for x in data] decorated.sort() return [x[1] for x in decorated] or shorter but possible less readable (and only in 2.4+): def shuffle(data): return [y[1] for y in sorted([(random(), x) for x in data])] Iain [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
shuffling elements of a list
Top