6 Replies - 386 Views - Last Post: 23 July 2013 - 02:57 AM Rate Topic: -----

#1 ogadit  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • 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  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4531
  • View blog
  • Posts: 7,902
  • 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
Was This Post Helpful? 0
  • +
  • -

#3 Michael26  Icon User is online

  • DIC-head, major DIC-head
  • member icon

Reputation: 362
  • View blog
  • Posts: 1,534
  • 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#)
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9387
  • View blog
  • Posts: 35,242
  • 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?
Was This Post Helpful? 0
  • +
  • -

#5 Golossos  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • 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

Was This Post Helpful? 0
  • +
  • -

#6 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1012
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: Sorting integers from highest to lowest

Posted 23 July 2013 - 12:12 AM

View PostGolossos, 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).
Was This Post Helpful? 0
  • +
  • -

#7 ogadit  Icon User is offline

  • New D.I.C Head

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

Re: Sorting integers from highest to lowest

Posted 23 July 2013 - 02:57 AM

View PostCurtis 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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1