Find Jobs
Hire Freelancers

Function for random sorting of an array with weights

$10-30 USD

Igangværende
Slået op over 10 år siden

$10-30 USD

Betales ved levering
I need someone to create a random sort for an array that has weights. I have an array with weights for example: $videos = array ( "video1" => 25, "video2" => 50, "video3" => 75, "video4" => 25, "video5" => 50, "video6" => 25, "video7" => 50, "video8" => 75, "video9" => 25, "video10" => 50 ) I want them to shuffle into a random order. I want it make all weights = 75 to show up towards the top of the sort MORE OFTEN than the 50. 50 more than 25. I DO NOT want all 75s before 50s, and all 50s before 25s. I have something currently that is working well, but I fear it is not performing ideally like I want. It is this: function wshuffle(&$array) { foreach($array as $k=>$v) $tmp_array[$k] = mt_rand(0,$v); arsort($tmp_array); foreach($tmp_array as $k=>$v) $out_array[$k] = $array[$k]; $array = $out_array; } I will not accept your bid: - If you are from India - If you do not speak english well - If you do not write well in english - If you do not tell me how many stripes are in the american flag when you respond
Projekt-ID: 4981130

Om projektet

7 forslag
Projekt på afstand
Aktiv 11 år siden

Leder du efter muligheder for at tjene penge?

Fordele ved budafgivning på Freelancer

Fastsæt dit budget og din tidsramme
Bliv betalt for dit arbejde
Oprids dit forslag
Det er gratis at skrive sig op og byde på jobs
Tildel til:
Brug Avatar.
"thirteen stripes" you ask me, thirteen lines of code I answer
$30 USD på 0 dag
5,0 (15 anmeldelser)
6,3
6,3
7 freelancere byder i gennemsnit $29 USD på dette job
Brug Avatar.
I can give you this function. Can you confirm there are only 3 weights 75, 50 and 25? Or will there be many different possible weights? Do you just want the high weight values to be **predisposed** (higher chance) of appearing first? And what type of distribution model are you after (quadratic, linear etc?) If you have no idea what I'm talking about, then my bid is for handling any number of different possible weights, and for larger weight values to more often appear at the top of the list but NOT ALWAYS, and you don't have to worry about the intricate details. Reminder: no milestone, no start.
$30 USD på 1 dag
5,0 (76 anmeldelser)
6,3
6,3
Brug Avatar.
13 stripes. I can code your sorting function with weights
$20 USD på 2 dage
5,0 (43 anmeldelser)
5,1
5,1
Brug Avatar.
G'day Greg, I could give you a probabilistic function where the chance of an entry appearing next is directly proportional to its weight. It would include a parameter to specify how 'strong' you want the weighting to be factored so you could adjust the output to your liking. Just a quick question, how long will the arrays be? I don't know how many stripes are in the American flag but I think there are 52 stars.
$40 USD på 2 dage
5,0 (7 anmeldelser)
5,1
5,1
Brug Avatar.
I can do this . I am a senior developer in php , perl and in others langages . For the number of stripes see my PM
$45 USD på 0 dag
4,4 (9 anmeldelser)
3,9
3,9
Brug Avatar.
13. I already have the answer ready.
$15 USD på 1 dag
0,0 (0 anmeldelser)
0,0
0,0

Om klienten

Flag for UNITED STATES
Dallas, United States
5,0
47
Betalingsmetode verificeret
Medlem siden sep. 15, 2008

Klientverificering

Tak! Vi har sendt dig en e-mail med et link, så du kan modtage din kredit.
Noget gik galt, da vi forsøgte at sende din mail. Prøv venligst igen.
Registrerede brugere Oprettede jobs i alt
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Indlæser forhåndsvisning
Geolokalisering er tilladt.
Din session er udløbet, og du er blevet logget ud. Log venligst ind igen.