answersLogoWhite

0

How can you sort a given array in vbnet?

Updated: 12/21/2022
User Avatar

Yitbarektaye

Lvl 1
14y ago

Best Answer

Use the built-in Array.Sort function.

Dim myData() As Integer = {1, 6, 9, 89, 8, 7, 4, 6, 6, 123, 142, 45, 45, 489, 4989}

Array.Sort(myData) Module Module1

Sub Main()

Dim Deck() As PlayingCard = New PlayingCard(99) {}

Dim i As Integer

Dim r As Random = New Random

For i = 0 To 99 'randomize the array

Deck(i) = New PlayingCard(r.Next(PlayingCard.CARDVALUE.Ace, PlayingCard.CARDVALUE.King + 1), r.Next(PlayingCard.CARDSUIT.Spades, PlayingCard.CARDSUIT.Diamonds + 1))

Next i

PlayingCard.AcesHigh = True

Array.Sort(Deck)

For i = 0 To 99

Console.WriteLine(Deck(i))

Next i

Console.ReadLine()

End Sub

End Module

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can you sort a given array in vbnet?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you sort the given contents of an array?

You would sort the given elements of an array by a bubble sort or heap sort code!!


When quick sort is preferred?

When you want to sort an array.


C program to solve the given array element in descending order?

#include#includeint main(){long int sort[10],i,j,t;printf("\n\ n Enter 10 Elements In Array To Sort In Descending Order:\n"); for(i=0;i


Can you modify the bubble sort algorithm to search to sort an array of characters instead of array of integers?

The bubble sort algorithm can be applied to an array of characters. Every character can be translated to an integer equivalent via the ascii table


What is the difference between sort and asort in PHP?

sort() will order the array by its values without preserving the keys. Use it when array is indexed numerically or when you do not care about the keys. asort() will also sort the array by its values, but it will preserve the key -> value association.


What is the code of sorting out an given unsorted array in text file for c plus plus?

Sorting arrays (of any type) can be achieved with the C++ standard library std::sort function: std::array<int, 5> a {9, 3, 5, 1, 7}; // fixed-length array std::vector<int> b {9, 3, 5, 1, 7}; // variable length array int c[] = {9, 3, 5, 1, 7}; // C-style array std::sort (a.begin(), a.end()); std::sort (b.begin(), b.end()); std::sort (c, c+5);


What are the Application of quick sort?

Sorting an array.


How do you display 15 numbers in an ascending order using an array?

Sort the array then traverse the array, printing the element values as you go.


Sort array in ascending descending order in python?

Using sorted(array,reverse=True)


How do you merge and sort an array using PHP?

To merge and sort an array in PHP you need to use the array_merge() and sort() functions like shown in the example below: <?php $array1 = array(1, 5, 3, 9, 7); $array2 = array(8, 2, 6, 4, 0); // merge the arrays $merge = array_merge($array1, $array2); // 1, 5, 3, 9, 7, 8, 2, 6, 4, 0 // sort the array sort($merge); // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ?>


How do you write a program that accepts 50 integer values and sort them in basic programming?

Create an array with 50 elements and input the integers one a time, filling the array. Use an insertion sort on the array for each input except the first. Alternatively, input the values first and then use insertion sort.


What happens if there are duplicate values in the array during a linear search?

Duplicate values have no effect on linear search other than to increase search times. When searching for a value that is duplicated, the index of the first element that matches the given value is returned. If you wish to return all indices that match the given value, you must either search the entire array to build a new array of indices, or sort the array so that all duplicates are allocated contiguously and return the range of indices.