Add a shuffle utility
This commit is contained in:
parent
a39c3ce06a
commit
4b2d6fcabb
1 changed files with 12 additions and 0 deletions
12
rowbot
12
rowbot
|
@ -97,6 +97,18 @@ any_file() {
|
||||||
fi
|
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
|
# misc
|
||||||
|
|
||||||
is_running () {
|
is_running () {
|
||||||
|
|
Loading…
Reference in a new issue