Selects n random elements from a list of (weight, item) tuples. Based on code snippet by Nick Johnson