Add a shuffle utility
This commit is contained in:
parent
a39c3ce06a
commit
4b2d6fcabb
12
rowbot
12
rowbot
|
@ -97,6 +97,18 @@ any_file() {
|
|||
fi
|
||||
}
|
||||
|
||||
shuffle() {
|
||||
local idx=0 spot tmp
|
||||
declare -n rowbot_array=$1
|
||||
|
||||
for (( ; idx < ${#rowbot_array[@]}; idx += 1 )); do
|
||||
spot=$(random 0 "${#rowbot_array[@]}")
|
||||
tmp=${rowbot_array[$idx]}
|
||||
rowbot_array[$idx]=${rowbot_array[$spot]}
|
||||
rowbot_array[$spot]=$tmp
|
||||
done
|
||||
}
|
||||
|
||||
# misc
|
||||
|
||||
is_running () {
|
||||
|
|
Loading…
Reference in New Issue