cloudflare / cloudflare/semver_bash

Sorting

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
268
Forks
57
PR merge metrics
No merged PRs in 30d

Description

This is my bubble sort funtion

``` bash
declare -a VERSION=( ... )
BUBBLE="1"
while [ "$BUBBLE" == 1 ]; do
BUBBLE="0"
for I in $(seq 0 "$((${#VERSIONS[@]} - 1))"); do
# Skip first element
[ "$I" == 0 ] && continue

PREVIOUS="$((I - 1))"
if semverGT "${VERSIONS[$PREVIOUS]}" "${VERSIONS[$I]}"; then
BUBBLE="1"
BUFFER="${VERSIONS[$I]}"
VERSIONS[$I]="${VERSIONS[$PREVIOUS]}"
VERSIONS[$PREVIOUS]="$BUFFER"
fi
done
done
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.