(https://s-media-cache-ak0.pinimg.com/originals/b5/72/44/b57244719973f2f6ef445f53cf20660a.jpg) | Random Sorting Let's say we have a collection of things with a weight property and some other data. Perhaps that collection got loaded according to a mod list, so the sequence starts in unknown state. One method of returning a random weighted element from such a set is to make a speed/space trade-off: create an array that will contain only index references to the original set, and insert multiple references according to weight. So if the first item encountered in the data collection has a weight of ten, then insert ten index entries into the look-up collection that point to that first item. |