How to sort the items in a Listbox using quicksort

4

I'm doing a project for the university that consists of making software that sort from a listbox using quicksort, BlubbleSort etc ... In VB.NET I made an array to generate the random numbers in the listbox, but my difficulty now is to get the numbers from this listbox to sort

    
asked by anonymous 16.05.2016 / 03:52

2 answers

2

Use a loop to add the data from the ListBox to an array using the CopyTo method.

Something like:

For i = 0 To ListBox1.Count - 1
    ListBox1.Items.CopyTo(seuarray, i)
Next
seuarray.Sort()
    
16.05.2016 / 17:00
1

The Array.Sort of the .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 values from the array then the Catharina solution helps.

    
17.05.2016 / 18:55