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

  • Home
  • SEARCH
  • 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 6546469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:42:42+00:00 2026-05-25T11:42:42+00:00

ok, lets see if i can explain this. i have a List<Games> _Games =

  • 0

ok, lets see if i can explain this.

i have a List<Games> _Games = new List<Games>(); which containts 870 Games.

i have a Title ( each page will have a diffrent title, which is not related to the games, but the page will have the same game count ).

now, what i want to do, is order the games, based by the title i provide.

i actually tried to do something like this:

_Games = _Games.OrderByDescending(g => Math.Abs(Title.GetHashCode()));

but the order of the games stays the same.

Anyone has an idea how this kind of sorting can be created?

EDIT: you can see something similar to what i try to acheive here : Game/Quote of the day – how to?

but the accpeted answer there returns only 1 game, i want to return all the games.

EDIT: Sample title’s : “Hello World”, “Goodbye” === Diffrent Titles…

EDIT: this was conceptual.. added _Games = so you wont fixate on small things like that and avoiding my real question.

  • 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-25T11:42:43+00:00Added an answer on May 25, 2026 at 11:42 am

    Your ordering attempt has two problems:

    1.) You try to order by a fixed value (the hash code of the title) – ordering is internally done by most sort routines by comparing two items and positioning them accordingly. Now if you project each item to a fixed value they all are coming up as equal and no sort order can be established.

    2.) You are not re-assigning the results of your ordering to your collection. You probably want something like

    _Games = _Games.OrderByDescending(g => g.Title).ToList();
    

    Edit:

    Judging by your comments you just want to shuffle the list of games using a random sequence that will always be the same for a given title. If so, you can use a Fisher-Yates Shuffle combined with a Random instance that you pass the hash code of the title:

    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source, Random rng)
    {
        T[] elements = source.ToArray();
        // Note i > 0 to avoid final pointless iteration
        for (int i = elements.Length-1; i > 0; i--)
        {
            // Swap element "i" with a random earlier element it (or itself)
            int swapIndex = rng.Next(i + 1);
            T tmp = elements[i];
            elements[i] = elements[swapIndex];
            elements[swapIndex] = tmp;
        }
        // Lazily yield (avoiding aliasing issues etc)
        foreach (T element in elements)
        {
            yield return element;
        }
    }
    

    Then you can use it like this:

    Random rng = new Random(Title.GetHashCode());
    _Games = _Games.Shuffle(rng).ToList();
    

    Keep in mind though that hash codes are not guaranteed to be stable, they can differ between platforms (.NET 32 vs 64 bit) and on each run time of your executable – it is only guaranteed that the same title will produce the same hash code within one execution of your program. If this is a problem for you, you might have to switch to your own method of determining a unique value for each title, i.e.:

    Random rng = new Random(GetUniqueValue(Title));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's see if I can explain myself, I have this models: class BillHeader(models.Model): number
I will see if I can explain this clearly enough. I have 2 web
Lets see if I can explain this. I am displaying a table in PHP
I screwed up my last post. Lets see if I can get this one
Ok, let's see if I can make this make sense. I have a program
Ok this is hard to explain, but here goes. I have a 3D list
Let's see if I can explain myself. I use vi-mode in bash, which is
Let's see if I can explain this properly. I am (unfortunately) using Access. I
Can someone explain this issue to me ? I have a listview that holds
let's see how to explain this issue. I have 4 activities and 1 layout

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.