diff --git a/sorting/README.md b/sorting/README.md index ee2ee88..bf41dec 100644 --- a/sorting/README.md +++ b/sorting/README.md @@ -6,4 +6,6 @@ Sketches that visualize sorting algorithms as they progress. ## Sketches -- **cocktail_shaker_line** - Sorting of a line using the cocktail shaker algorithm (double bouble sort I believe). Needs reworking as the colors and movement of the line is not as expected (colors shift, movement doesn't properly correlate). \ No newline at end of file +- **cocktail_shaker_line** - Sorting of a line using the cocktail shaker algorithm (double bouble sort I believe). Needs reworking as the colors and movement of the line is not as expected (colors shift, movement doesn't properly correlate). + +- **insertion_sort_line** - Sorting of a line using the insertion sort algorithm. \ No newline at end of file diff --git a/sorting/insertion_sort_line/insertion_sort_line.pyde b/sorting/insertion_sort_line/insertion_sort_line.pyde new file mode 100644 index 0000000..d9d0da3 --- /dev/null +++ b/sorting/insertion_sort_line/insertion_sort_line.pyde @@ -0,0 +1,8 @@ +def setup(): + +def draw(): + if unsorted: + get = unsorted.pop(0) + for index, num in enumerate(sorted): + if sorted[index] < sorted[index + 1] and sorted[index + 1] >= get: + sorted.append( diff --git a/sorting/insertion_sort_line/sketch.properties b/sorting/insertion_sort_line/sketch.properties new file mode 100644 index 0000000..2456b0a --- /dev/null +++ b/sorting/insertion_sort_line/sketch.properties @@ -0,0 +1,2 @@ +mode=Python +mode.id=jycessing.mode.PythonMode