Jump to content
Sign in to follow this  
unshmettr

Shuffle float Array

Recommended Posts

Posted (edited)

How do I shuffle a float array vex?

Edited by unshmettr

Share this post


Link to post
Share on other sites

Hi,

Here is one way:

int source [ ] = array ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 );

float weights [ ] = array ( );
for ( int i = 0; i < len ( source ); ++i )
    weights [ i ] = rand ( i + 345.2342 + i * 567.213 );

int order [ ] = argsort ( weights );
source = reorder ( source, order );
    
i[]@array = source;

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×