# Sorting algorithm extension for blocks

**URL:** https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260
**Category:** Show & Tell
**Created:** [November 9, 2022, 10:43pm UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260 "2022-11-09T22:43:40Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [November 9, 2022, 10:43pm UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260/1 "2022-11-09T22:43:40Z")

</div>

@richard asked for it on stream, so here it is!  
A quick sort algorithm fitted for blocks - the method is available in both ascending and descending order.  
The blocks (really only one):

 ![arcade-screenshot (1)](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/82fb420526ebb2c5fd2c623bb400c8606eb43a6a.png)  
Have fun with it or whatever, peace!

> **[GitHub - S0m3randomguy/quick-sort: A MakeCode project](https://github.com/s0m3randomguy/quick-sort/)**
>
> A MakeCode project. Contribute to S0m3randomguy/quick-sort development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![Kiwiphoenix364](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kiwiphoenix364/32/14368_2.png) [@Kiwiphoenix364](https://forum.makecode.com/u/Kiwiphoenix364)
#### Post date: [November 10, 2022, 1:19am UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260/2 "2022-11-10T01:19:39Z")

</div>

Lol you beat me to it…

This is cool good job!

---

<div class="post-metadata">

### Author: ![isoffline](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/isoffline/32/8791_2.png) [@isoffline](https://forum.makecode.com/u/isoffline)
#### Post date: [November 10, 2022, 4:41am UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260/3 "2022-11-10T04:41:26Z")

</div>

Wait this EXIST YEHEY FINALLY IVE BEEN WAITING FOR THIS

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)
#### Post date: [November 27, 2023, 5:50pm UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260/4 "2023-11-27T17:50:48Z")

</div>

Can you explain why this code doesn’t work?

> **[Sorting](https://arcade.makecode.com/S87143-74956-30837-15068)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

B to organise array and display it.  
I think the extension breaks when trying to sort an array that’s already sorted

---

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [November 27, 2023, 6:43pm UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260/5 "2023-11-27T18:43:10Z")

</div>

Fixed! Thanks for pointing this out, I did make a mistake here. Because I was directly referencing the array parameter, when I used `array.pop()` in the sort method, it removed an element from the original array.

> <https://github.com/S0m3randomguy/quick-sort/commit/ad124b53904f62ff6995adcf1e1832c0fca6ab1b>

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)
#### Post date: [December 18, 2023, 5:45am UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260/6 "2023-12-18T05:45:08Z")

</div>

Uhh @sarge it’s still broken…

---

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [December 18, 2023, 6:32pm UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260/7 "2023-12-18T18:32:16Z")

</div>

Still the same issue?

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)
#### Post date: [December 18, 2023, 6:49pm UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260/8 "2023-12-18T18:49:28Z")

</div>

Yeah if you look at the example I gave, the issue still persists, even after re-downloading the extension

---

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [December 18, 2023, 9:14pm UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260/9 "2023-12-18T21:14:22Z")

</div>

Should be fine now. Turns out I fixed the issue, but I didn’t make a release so you couldn’t pull it 😅

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)
#### Post date: [December 18, 2023, 9:18pm UTC](https://forum.makecode.com/t/sorting-algorithm-extension-for-blocks/16260/10 "2023-12-18T21:18:39Z")

</div>

Thanks!
