Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6048549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:28:33+00:00 2026-05-23T07:28:33+00:00

I need to sort a highscore file for my game I’ve written. Each highscore

  • 0

I need to sort a highscore file for my game I’ve written.

Each highscore has a Name, Score and Date variable. I store each one in a List.

Here is the struct that holds each highscores data.

struct Highscore
{
    public string Name;
    public int Score;
    public string Date;

    public string DataAsString()
    {
        return Name + "," + Score.ToString() + "," + Date;
    }
}

So how would I sort a List of type Highscores by the score variable of each object in the list?

Any help is appreciated 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:28:33+00:00Added an answer on May 23, 2026 at 7:28 am

    I don’t know why everyone is proposing LINQ based solutions that would require additional memory (especially since Highscore is a value type) and a call to ToList() if one wants to reuse the result. The simplest solution is to use the built in Sort method of a List

    list.Sort((s1, s2) => s1.Score.CompareTo(s2.Score));
    

    This will sort the list in place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to sort on a date-field type, which name is mod_date. It works
I need to sort tuples according to the second element of each tuple but
I need to sort a field name of that contains some name, NULL and
I need to sort an array of ActiveRecord objects by the value in one
I need to sort a data frame by date in R. The dates are
i need to sort a large XML file and i've been reading that placing
I need some sort of way to store key/value pairs where the value can
I need to sort through an array and sort each individual row in array
I need to sort by date but the date is stored as text in
I need to sort 20+ arrays, already on the GPU, each of the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.