Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 55f94c1

Browse files
committed
Finishing bubble sort
1 parent 2a9c17f commit 55f94c1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
items=("$@")
4+
len=${#items[@]}
5+
6+
for (( i = len - 1; i > 0 ; i-- )); do
7+
for (( j = 0; j < i; j++ )); do
8+
if (( items[j] > items[$(( j + 1 ))])); then
9+
temp=${items[j]}
10+
items[$j]=${items[$((j + 1))]}
11+
items[$(( j + 1 ))]=${temp}
12+
fi
13+
done
14+
done
15+
16+
echo "${items[@]}"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /