mercredi 3 octobre 2018

Pseudo random sorting based on specified parameters

I have 10 000 of IDs, that are sorted randomly. This random sequence has to be saved for later use. Of course, it is possible to save current random sequence as it is, but this approach is very bulky and it requires a lot of space, considering that there can be lots of possible sequences

Is there a way to imitate random sorting and arrange IDs using a method with specified parameters, and use same parameters later for re-creating same sequence?

I am looking for something like this:

public function pseudoRandomSort($ids, $var1, $var2, $var3, ...)
{
    // do some pseudo random staff with $ids using $var1, $var2, $var3...
    return $ids;    
}

Considering that I have access to $ids sorted in standard ascending way, there should be a way to generate specific pseudo-random sequence using $var1, $var2, $var3...

Sorting may be not perfectly random from mathematical point of view, but it has to look like random for a regular person, viewing this sequence of IDs. And one more thing: this method shouldn't consume a lot of server resources.




Aucun commentaire:

Enregistrer un commentaire