Vote count:
0
I'm new to ruby. I wanted to save array into value that rand evaluates(let's say 0.78346....) number with following strings.
rows = ["hello", "nihao", "konnichiwa", "hallo"]
myrand = Random.new(100) # seed - 100
rows.sort_by!{myrand.rand } => result could be - ["nihao ", "hello", "konnichiwa", "hallo"]
For example: [[0.12232, "nihao"],[0.53434, "hello"],[0.333, "konnichiwa"],[0.99, "hallo"]]
How can I get this array from rows.sort_by!{myrand.rand }?
asked 42 secs ago
Aucun commentaire:
Enregistrer un commentaire