mroth / weightedrand

:balance_scale: Fast weighted random selection for Go
MIT License
393 stars 50 forks source link

Optimize: We can remove the sorting in new instance #38

Open win5do opened 3 weeks ago

win5do commented 3 weeks ago

https://github.com/mroth/weightedrand/blob/82b9ec74aca51314533f5ad81822c7b722021e58/weightedrand.go#L41-L44

Sort doesn't make any sense for randomness. And it will change the order of the original array, which is not a good practice.