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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:54:45+00:00 2026-06-18T11:54:45+00:00

I am trying to arrange this multidimensional array to ascending or descending. However, I

  • 0

I am trying to arrange this multidimensional array to ascending or descending. However, I need the relation between column 1 and 2 to still be together(meaning I need the data of eg. array[0,1] and array[0,2] to be together or related in some way or another. This are my codes as of right now.

int[,] time = new int[5,2]{{0,4},{1,5},{5,10},{3,4},{0,2}};
var sorted = from x in Enumerable.Range(0, time.GetLength(0))
                     from y in Enumerable.Range(0, time.GetLength(1))
                     select new{
                         X = x,
                         Y = y,
                         Value = time[x,y]
                    }into point
                    orderby point.Value descending
                    select point;

This works but it splits all my data apart. Is there a way to sort them while keeping the relation of column 1 and 2 together?

  • 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-06-18T11:54:46+00:00Added an answer on June 18, 2026 at 11:54 am

    It sounds like you want to store your data in a multi-dimensional array, but keep each row in the array as a separate atomic unit. And additionally, the comparison of each “point” is by X, and then Y.

    int[,] time = new int[5, 2] { { 0, 4 }, { 1, 5 }, { 5, 10 }, { 3, 4 }, { 0, 2 } };
    
    var sorted = from x in Enumerable.Range(0, time.GetLength(0))
                         select new Point()
                         {
                             X = time[x,0],
                             Y = time[x,1]
                         } into point
                         orderby point.X ascending , point.Y ascending 
                         select point;
    
    int[,] sortedTime = new int[5,2];
    int index = 0;
    foreach (var testPoint in sorted)
    {
      Point aPoint = (Point) testPoint;
      sortedTime.SetValue(aPoint.X, index, 0);
      sortedTime.SetValue(aPoint.Y, index, 1);
    
      index++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to arrange an array of movies in alphabetical order, ignoring case. My
I'm trying to arrange a group of pages in to an array and place
I am trying to figure out of there is a way to arrange this
I am having this array. Last few hours I have been trying to loop
I am trying to use a wxSizer to arrange widgets inside a panel. I
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to figure out how I can do this properly. The print_r looks like
trying to figure out why this is happening - I have an input text
i'm trying to use a regexp to arrange some text, with re.sub . Let's
Im trying to create an array of object from ul li tags using jQuery

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.