Solved

VB.net sort an array

Posted on 2013-05-22
4
386 Views
Last Modified: 2013-05-22
Hi

I declared the following array:  Dim arrIntegers(1000) as integer

It holds a list of arrays that re not in order.

I need to sort the  numbers held in the array into descending order

and then loop through these in that order.

How would I do that?
0
Comment
Question by:murbro
  • 2
4 Comments
 
LVL 42

Assisted Solution

by:sedgwick
sedgwick earned 250 total points
ID: 39188969
arrintegers.OrderByDescending()
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39188971
U need:
import System.Linq
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 39189069
You can also just use the shared Array.Sort() and Array.Reverse() methods:
        Dim arrIntegers(1000) As Integer

        Array.Sort(arrIntegers)
        Array.Reverse(arrIntegers)

        For i As Integer = 0 To arrIntegers.GetUpperBound(0)
            Debug.Print(i & " = " & arrIntegers(i))
        Next

Open in new window

0
 

Author Closing Comment

by:murbro
ID: 39189086
Thanks very much
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now