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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:54:35+00:00 2026-06-03T01:54:35+00:00

I have got a weird situation. There is an array that has got numbers

  • 0

I have got a weird situation. There is an array that has got numbers from 1 – 20, the other array has got all the random numbers. Using Array.Sort(rand) I’m able to sort the randnos array. But how can I give a rank to those numbers using the numbers array.

Should I use the sorting algorithms? Or are there any available stuff?

  • 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-03T01:54:39+00:00Added an answer on June 3, 2026 at 1:54 am

    Given an array of random numbers:

    var rand = new Random();
        // generate an array of 10 random numbers between 1 and 100
    var randNumbers = Enumerable.Range(1,10)                  // enumerable 1 to 10
                                .Select(_ => rand.Next(100))  // replace with random num
                                .ToArray();                   // convert to array
    

    Here is a method to sort them and provide their rank, as a string number-rank:

    var sorted = randNumbers.OrderBy(x => x)                   // sort by the number
                            .Select((val,idx) =>               // given the value and the index
                                     String.Format("{0}-{1}",  // return value-index as string
                                            val,idx+1))
                            .ToArray();                        // convert to array
    

    Prints (for example):

    21-1 
    30-2 
    31-3 
    32-4 
    40-5 
    51-6 
    67-7 
    70-8 
    84-9 
    99-10
    

    Note that you could also have done:

    randNumbers.Sort() // sort in place first
    var sorted = ... // same as above without the OrderBy
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a weird iFrame situation. I have a search button that, when clicked,
I have got a field that has been setup to allow for Null, but
I have got an ActiveX Control that gets an image from a fingerprint device
Hey guys I got a weird issue.. I have a datalist that's only loaded
I've got a weird linker issue. I have code that looks like so: double
I have sort of weird situation and I am not sure why it is
I have got a weird problem here, and more interesting that it works fine
I have got an old site that has recently been displaying an error which
I've got a weird problem that I can't understand... I have a simple HelloWorld
I have a weird situation where I open a form from my application, hide

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.