Solved

VB.net sort an array

Posted on 2013-05-22
4
389 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

839 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