[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VB.net sort an array

Posted on 2013-05-22
4
Medium Priority
?
413 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 42

Assisted Solution

by:Meir Rivkin
Meir Rivkin earned 1000 total points
ID: 39188969
arrintegers.OrderByDescending()
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39188971
U need:
import System.Linq
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1000 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:Murray Brown
ID: 39189086
Thanks very much
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

650 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