How to draw items from a Listbox using quicksort

Asked

Viewed 87 times

4

I am carrying out a project for the University that consists in carrying out a software that makes the 'Sort' of a listbox using quicksort , Blubblesort etc... In VB.NET I made an array to generate the random numbers of the listbox , but my difficulty now and pick the numbers of this listbox to perform the Sort

2 answers

2


Use a repeat loop to add Listbox data to an array using the Copyto method.

Something like:

For i = 0 To ListBox1.Count - 1
    ListBox1.Items.CopyTo(seuarray, i)
Next
seuarray.Sort()

1

The very one Array.Sort of. Net Framework already brings some ease to you because behind it already implements algorithms like Quicksort and Heapsort depending on the size of the input array. In the worst case the complexity is O(n log n)

If the difficulty is just getting the array values then the Catharina solution already helps you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.