edits for style
add seed for RNG
use clone to protect R vector from being sorted