We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4abbf9a commit 05c090fCopy full SHA for 05c090f
ShakerSort/Class1.cs
@@ -4,12 +4,13 @@ namespace SortingAlgos
4
{
5
public class ShakerSort
6
7
+ private static bool swapped = true;
8
+
9
public static void Sort(int[] input)
10
11
int len = input.Length;
- bool swapped = true;
12
- while (swapped == true)
13
+ while (swapped)
14
15
swapped = false;
16
@@ -24,12 +25,8 @@ public static void Sort(int[] input)
24
25
}
26
27
- if (swapped == false)
28
- {
29
- return;
30
- }
31
-
32
- swapped = false;
+ // If nothing was changed, return
+ if (swapped == false) return;
33
34
for (int i = len - 2; i > 0; i--)
35
@@ -41,11 +38,6 @@ public static void Sort(int[] input)
41
38
swapped = true;
42
39
43
40
44
45
46
47
48
49
50
51
0 commit comments