# How to sort integers without an array list

Page 1 of 1

## 2 Replies - 506 Views - Last Post: 06 October 2012 - 11:13 PMRate 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=294566&amp;s=3f98a7fcffd8079824e3e200829d95da&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 xonewingedangelx

Reputation: 0
• Posts: 21
• Joined: 14-June 12

# How to sort integers without an array list

Posted 06 October 2012 - 08:17 PM

In my program I have six different integers as counters so like a, b, c, d, e, f. I have buttons in my code that increase and decrease the value of the counters. I'm trying to display the highest value integer and 2nd highest value without the use of an array. If no integer have been increased, nothing should appear. If only one value has been increased, only the highest value should appear. If the highest value is tied with another value, the value that was previously higher will be the highest value.

So far, I tried doing it with this approach. !! NOT MY ACTUAL CODE MORE OF PSUEDO CODE.
```int a, b, c ,d ,e ,f;
int firstPopular;
int secondPopular;
int thirdPopular;
and so on.

if (a > firstPopular) {
firstPopular = a;
}

and on and on to F

then

if (a < firstPopular) {
secondPopular =a;
}

and you know the rest.

```

However, this method doesn't work very well. Any ideas?

Is This A Good Question/Topic? 0

## Replies To: How to sort integers without an array list

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11390
• Posts: 42,919
• Joined: 27-December 08

## Re: How to sort integers without an array list

Posted 06 October 2012 - 08:56 PM

Serious question- why don't you want to use an array?

### #3 xonewingedangelx

Reputation: 0
• Posts: 21
• Joined: 14-June 12

## Re: How to sort integers without an array list

Posted 06 October 2012 - 11:13 PM

I ended up using an array and put each counter in and then sorted the array from least to greatest. then I used array.length -1 and array.length -2 in order to determine the top two most popular. However, now im stuck on what to do if the top two are tied in value.
Im using an if statement for the most popular
if (aCounter == highestNumber && aCounter != 0) {
"highestNumber is aCounter and display text"
}

if (bCounter == nexthighestNumber && isnt 0) {
"display text and next highest number is b counter"
}

what if statement should I do in order to fix my tie?