# We need to make a pure function where the pinde need to get sorted with highest to the left

**URL:** <https://discourse.processing.org/t/we-need-to-make-a-pure-function-where-the-pinde-need-to-get-sorted-with-highest-to-the-left/26011>\
**Category:** Coding Questions\
**Created:** [December 7, 2020, 9:33am UTC](https://discourse.processing.org/t/we-need-to-make-a-pure-function-where-the-pinde-need-to-get-sorted-with-highest-to-the-left/26011 "2020-12-07T09:33:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ctc2502](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@ctc2502](https://discourse.processing.org/u/ctc2502)\
**Post date:** [December 7, 2020, 9:33am UTC](https://discourse.processing.org/t/we-need-to-make-a-pure-function-where-the-pinde-need-to-get-sorted-with-highest-to-the-left/26011/1 "2020-12-07T09:33:12Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

int liste = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};  
int index = 0;

void setup() {  
size(400, 400);  
frameRate(10);  
blanding(0, liste);  
}

void draw() {  
display(0, liste);  
}

void display(int plads, int talListe) {  
int value = talListe[plads];  
rect(40_plads, height, 40, -20_value);  
//text();  
if (plads \< talListe.length-1) {  
display(++plads, talListe);  
}  
}

void sortering() {  
}

int blanding(int plads, int talListe) {  
int pickRandom = int(random(0, 10));  
int valueA = talListe[plads];  
int valueB = talListe[pickRandom];  
talListe[plads]=valueB;  
talListe[pickRandom]=valueA;

if (plads \< talListe.length-1) {  
blanding(++plads, liste);  
return talListe;  
} else {  
println(talListe);  
return talListe;  
}  
}

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [December 7, 2020, 7:03pm UTC](https://discourse.processing.org/t/we-need-to-make-a-pure-function-where-the-pinde-need-to-get-sorted-with-highest-to-the-left/26011/2 "2020-12-07T19:03:03Z")

</div>

to be honest, please copy the text from your subject/ headline into the text field below it.

Write a brief good subject line

You can go back and edit your post with the pencil icon

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [December 7, 2020, 7:15pm UTC](https://discourse.processing.org/t/we-need-to-make-a-pure-function-where-the-pinde-need-to-get-sorted-with-highest-to-the-left/26011/3 "2020-12-07T19:15:52Z")

</div>

concerning your sorting:

please make a for-loop over all items in the liste.

check if one element is \< then the next - if so **swap** the two

repeat this until no swapping was necessary

**Remark**

basically you can call sortering() in keyPressed() like here:

```auto
void keyPressed() {
  sortering();
}

```

Chrisir
