Skip to content

Sorting #9

@szepeviktor

Description

@szepeviktor

This is my bubble sort funtion

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions