# Arrange array in ascending order

**URL:** <https://discourse.processing.org/t/arrange-array-in-ascending-order/22314>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [July 2, 2020, 5:16am UTC](https://discourse.processing.org/t/arrange-array-in-ascending-order/22314 "2020-07-02T05:16:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@alex](https://discourse.processing.org/u/alex)\
**Post date:** [July 2, 2020, 5:16am UTC](https://discourse.processing.org/t/arrange-array-in-ascending-order/22314/1 "2020-07-02T05:16:57Z")

</div>

Hi,  
How do i arrange an array of number for e.g.  
int [] array = {3,2,7,4,9,1};  
into ascending order without using the sort() function?

Thanks

---

<div class="post-metadata">

**Author:** ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)\
**Post date:** [July 2, 2020, 5:58am UTC](https://discourse.processing.org/t/arrange-array-in-ascending-order/22314/2 "2020-07-02T05:58:53Z")

</div>

Did your professor recommend any sorting algorithms?

---

<div class="post-metadata">

**Author:** ![alex](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@alex](https://discourse.processing.org/u/alex)\
**Post date:** [July 2, 2020, 6:17am UTC](https://discourse.processing.org/t/arrange-array-in-ascending-order/22314/3 "2020-07-02T06:17:40Z")

</div>

Not really.  
I was trying to do this using for loops. Can’t seem to get the conditions right.

---

<div class="post-metadata">

**Author:** ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)\
**Post date:** [July 2, 2020, 6:19am UTC](https://discourse.processing.org/t/arrange-array-in-ascending-order/22314/4 "2020-07-02T06:19:05Z")

</div>

Might try with Bubble sort …

> **[Bubble Sort Algorithm in Data Structures](https://www.w3schools.in/data-structures-tutorial/sorting-techniques/bubble-sort-algorithm/)**
>
> Bubble Sort Algorithm - Bubble Sort Algorithm is used to arrange N elements in ascending order, and for that, you have to begin with 0th element and compare it with the first
