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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:12:37+00:00 2026-05-13T15:12:37+00:00

I have the following array: private int[,] testSamples = new testSamples[101,101]; It’s supposed to

  • 0

I have the following array:

private int[,] testSamples = new testSamples[101,101];

It’s supposed to represent a roster, with column 0 to 100 and row 0 to 100. In this rosters, various chemical liquids are dropped. The person I’m doing this for wants to work in such a way that he can take care of the container with the most liquid in it first.

So, I need to get the data out and printed in this manner:

testSamples[35,40] = 12
testSamples[11,12] = 11
testSamples[92,14] = 10
testSamples[18,3] = 10
testSamples[1,61] = 7
...

For instance.
I’ve been cracking my head over this for a few days, I’ve looked into some other questions here on StackoverFlow, but I can’t get any of them to work.

Is there a way to do this, or should I give up on arrays and go for another sort of container, like ArrayLists or List items?

  • 1 1 Answer
  • 1 View
  • 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-13T15:12:37+00:00Added an answer on May 13, 2026 at 3:12 pm

    Here’s a suggestion that I think ends up being quite similar to Richard’s, but without using LINQ.

    Write a quick struct (something like this may even exist already) that includes three values: x, y, and value. Like this:

    public struct SampleSlot : IComparable<SampleSlot> {
        public int X;
        public int Y;
        public int Value;
    
        public SampleSlot(int x, int y, int value) {
            X = x;
            Y = y;
            Value = value;
        }
    
        public int CompareTo(SampleSlot other) {
            return Value.CompareTo(other.Value);
        }
    }
    

    Then you can collapse your int[,] array into any sortable one-dimensional collection of SampleSlot objects you like; I’d probably go with a List<SampleSlot>:

    List<SampleSlot> slotsList = new List<SampleSlot>();
    
    for (int i = 0; i < testSamples.GetLength(0); ++i) {
        for (int j = 0; j < testSamples.GetLength(1); ++j) {
            slotsList.Add(new SampleSlot(i, j, testSamples[i, j]));
        }
    }
    
    slotsList.Sort();
    
    // assuming you want your output in descending order
    for (int i = slotsList.Count - 1; i >= 0; --i) {
        SampleSlot slot = slotsList[i];
        Console.WriteLine("testSamples[{0},{1}] = {2}", slot.X, slot.Y, slot.Value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have taken following array; to fill-up gallery: private Integer[] mImageIds = { R.drawable.one,
I have the following class: #include <array> template<unsigned short D> class Point { private:
I have the following string: 2,26,17,33,6,14,9,29,1 And an array of int , usedIds .
I have the following class: private class Info{ public String A; public int B;
I have the following structure: private struct S_indiv { public int[] x; public int
I have the following class: class Position { private double x,y; private int id;
I have the following structure: template <class T> struct Array{ int lenght; T *
I have following array, that I need to operate by hand on bitmaps. const
I have the following array: $franchise_a_status[] = array( 'id' => $franchise['franchise_id'], 'text' => $franchise['franchise_surname'].
I have the following array(in python): arr= ['\n', ' a#B\n', ' c#D\n'] Now I

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.