# Sorting an Array (Ascending Order)

Page 1 of 1

## 1 Replies - 2899 Views - Last Post: 21 May 2009 - 09:44 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=106332&amp;s=6ca5b3b48f5478e5a8dea562032c0239&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 zanyrogue

• D.I.C Head

Reputation: 0
• Posts: 91
• Joined: 16-January 09

# Sorting an Array (Ascending Order)

Posted 21 May 2009 - 08:33 AM

Hi, I need help in being able to sort this array. I'd like to sort it in ascending order.

```class Ascending2
{
public static void main (String [] args)
{

int n[];
n = new int[5];

n[0]=9;
n[1]=5;
n[2]=11;
n[3]=5;
n[4]=8;

for (int i=0; i<5; i++)
System.out.println(n[i]);

}
}

```

Is This A Good Question/Topic? 0

## Replies To: Sorting an Array (Ascending Order)

### #2 ralph_komer

• D.I.C Head

Reputation: 13
• Posts: 71
• Joined: 12-May 09

## Re: Sorting an Array (Ascending Order)

Posted 21 May 2009 - 09:44 AM

You need to apply a sorting algorithm to this array like selection, insertion, bubble or quick sort. If you have any issues in implementation then only we can help you.
Was This Post Helpful? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }