# Sorting integers from highest to lowest

Page 1 of 1

## 6 Replies - 1361 Views - Last Post: 23 July 2013 - 02:57 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=325337&amp;s=cfcc85c46ff846ed87383c51eb41bac9&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

Reputation: 1
• Posts: 22
• Joined: 31-July 12

# Sorting integers from highest to lowest

Posted 22 July 2013 - 09:09 AM

Hi I am make a game which adds points when the player captures the flags
if the player hits the enemy the game is over and the points are saved in the settings which are in turn used in the hi score form
what i need to ask is how to sort the scores form highest to lowest

note: I am currently using a listView
Is This A Good Question/Topic? 0

## Replies To: Sorting integers from highest to lowest

### #2 Curtis Rutland

• （╯°□°）╯︵ (~ .o.)~

Reputation: 5103
• Posts: 9,283
• Joined: 08-June 10

## Re: Sorting integers from highest to lowest

Posted 22 July 2013 - 09:13 AM

ListViews are UI elements. You shouldn't be using them to store your data; they should be used to display data you're storing in a List or Array. Sorting is simple with lists and arrays:

List.Sort
Array.Sort
OrderBy

### #3 Michael26

• Futurama: Insert funny joke here

Reputation: 414
• Posts: 1,664
• Joined: 08-April 09

## Re: Sorting integers from highest to lowest

Posted 22 July 2013 - 09:13 AM

If sorting is the only problem try something like this(How to sort a ListView control by a column in Visual C#)

### #4 modi123_1

• Suitor #2

Reputation: 13969
• Posts: 55,771
• Joined: 12-June 08

## Re: Sorting integers from highest to lowest

Posted 22 July 2013 - 09:14 AM

If you had a dataset as your data source to your list view (or any collection for that matter) then it would be a trivial issue, right? I am guessing you are not doing that?

### #5 Golossos

Reputation: 13
• Posts: 118
• Joined: 29-June 13

## Re: Sorting integers from highest to lowest

Posted 22 July 2013 - 10:57 PM

You would have to do an
```arrayName.sort()
```
then implement the array contents to the list in question. Or a
```List.sort()
```

Correct me if I am wrong here.

This post has been edited by Golossos: 22 July 2013 - 10:59 PM

### #6 Momerath

• D.I.C Lover

Reputation: 1020
• Posts: 2,463
• Joined: 04-October 09

## Re: Sorting integers from highest to lowest

Posted 23 July 2013 - 12:12 AM

Golossos, on 22 July 2013 - 10:57 PM, said:

Correct me if I am wrong here.

You are both right and wrong Those would sort from low to high but a quick review of the methods should suggest how you can reverse the sort (or array).

Reputation: 1
• Posts: 22
• Joined: 31-July 12

## Re: Sorting integers from highest to lowest

Posted 23 July 2013 - 02:57 AM

Curtis Rutland, on 22 July 2013 - 09:13 AM, said:

ListViews are UI elements. You shouldn't be using them to store your data; they should be used to display data you're storing in a List or Array. Sorting is simple with lists and arrays:

List.Sort
Array.Sort
OrderBy

Curtis Rutland I am currently using the collection in the projects settings
i am using it to display the scores