Skip to content
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ This file lists everyone, who contributed to this repo and wanted to show up her
- Trashtalk
- Cyrus Burt
- Patrik Tesarik
- Neverik
- Ken Power
- PaddyKe
- PaddyKe
4 changes: 4 additions & 0 deletions book.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
{
"lang": "emojic",
"name": "Emojicode"
},
{
"lang": "st",
"name": "Smalltalk"
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions contents/bubble_sort/bubble_sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with
[import:3-28, lang:"lisp"](code/lisp/bubble_sort.lisp)
{% sample lang="nim" %}
[import:5-9, lang:"nim"](code/nim/bubble_sort.nim)
{% sample lang="st" %}
[import:2-15, lang:"smalltalk"](code/smalltalk/bubble.st)
{% sample lang="f90" %}
[import:19-40, lang:"fortran"](code/fortran/bubble.f90)
{% sample lang="scala" %}
Expand Down Expand Up @@ -113,6 +115,8 @@ Trust me, there are plenty of more complicated algorithms that do precisely the
[import, lang:"nim"](code/nim/bubble_sort.nim)
{% sample lang="f90" %}
[import, lang:"fortran"](code/fortran/bubble.f90)
{% sample lang="st" %}
[import, lang:"smalltalk"](code/smalltalk/bubble.st)
{% sample lang="scala" %}
[import, lang:"scala"](code/scala/bubble_sort.scala)
{% sample lang="emojic" %}
Expand Down
18 changes: 18 additions & 0 deletions contents/bubble_sort/code/smalltalk/bubble.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"Add this method to the SequenceableCollection class in the browser:"
bubbleSort
"Bubble sort for a collection."
| len swapper thisElem nextElem |
len := self size.
1 to: len - 1 do: [ :iteration |
1 to: len - 1 do: [ :index |
thisElem := self at: index.
nextElem := self at: index + 1.
(thisElem > nextElem) ifTrue: [
self at: nextIndex put: thisElem.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nextIndex no longer exists, this should be thisIndex + 1

self at: thisIndex put: nextElem.
]
]
]

"Then run this anywhere in your code: "
#(4 3 2 1 6 5) bubbleSort "outputs: #(1 2 3 4 5 6)"