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 701437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:36:36+00:00 2026-05-14T03:36:36+00:00

I have a problem which I cant seem to find answer to through searches

  • 0

I have a problem which I cant seem to find answer to through searches (either that or I am searching for the completely wrong thing!). I have a list of items called "Top 10" in a sortedlist item that is populated from my DB (SortedList<int, string> where int is position and string is item). I want to be able to move items up & down the list order at the click of a button and then save the new order back to the DB. I am OK with the DB part it is just the re-ordering I am really struggling with. Is a SortedList the correct collection for this?

Many thanks for any advice offered.

  • 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-14T03:36:36+00:00Added an answer on May 14, 2026 at 3:36 am

    A SortedList is for maintaining order within your SortedList as you add or remove items from it.

    You should create a custom list of your objects and then sort on property of that object.

    So if your entry in your database was like this you could place it in an object, add it to a list and then sort it using Lambda on which ever criteria you like

    public class LeaguePosition
    {
        public int Position { get; set; }
        public string Team { get; set; }
    }
    
    List<LeaguePosition> League = new List<LeaguePosition>();
    League.Add(new LeaguePosition() { Position = 2, Team = "Wolves" });
    League.Add(new LeaguePosition() { Position = 3, Team = "Spurs" });
    League.Add(new LeaguePosition() { Position = 1, Team = "Villa" });
            
    League.Sort((teamA, teamB) => teamA.Position.CompareTo(teamB.Position));
    

    You can also then use RemoveAt() and Insert() to move items about to custom positions within the list.

    LeaguePosition teamToMove = League[1];
    League.RemoveAt(1);
    League.Insert(2, teamToMove);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't seem to find a .NET answer to this problem, which I would
I have a problem, which I do not seem to be able to solve...
Fairly straightforward scenario, for which I can't seem to find an answer anywhere :
I have a problem which requires me to parse several log files from a
I have a problem which I think is related to forward declarations, but perhaps
I have a very simple problem which requires a very quick and simple solution
I have a problem with a string in C++ which has several words in
I have a problem with an application which uses the same stored procedure over
I have a problem with a little .Net web application which uses the Amazon
I have a problem in my project with the .designer which as everyone know

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.