# Sorting Algorithms

Page 1 of 1

## 1 Replies - 1786 Views - Last Post: 03 March 2012 - 05:37 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=269146&amp;s=e600283799209c8980ebe9dadf5f1dd7&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 DivaStyle

• New D.I.C Head

Reputation: 0
• Posts: 1
• Joined: 02-March 12

# Sorting Algorithms

Posted 02 March 2012 - 02:25 PM

I am taking a programming class for the first time and I have an assignment with the following criteria:
Allows the user to enter 10 integers for sorting
Allows the user to select one of two types of sorting techniques (bubble sort and selection sort)
Allows the user to select either the ascending or descending order
Displays the sorted list of numbes according to the options selected by the user.

I've written the code, which I'm not sure is correct, but I've tried. However, I'm not sure how to write the codes for the sort techniques. Would you please give me some direction and help if the code below is not what it needs to be? Thanks

```Public Class frmMain

' module-level array
Private strIntegers(9) As String
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
' allow user to enter 10 integers for sorting
' stores ten integers in the module-level
' strIntegers array

lstNumbers.Items.Clear()

For intSub As Integer = 0 To strIntegers.GetUpperBound(0)
strIntegers(intSub) =
InputBox("Enter 10 Numbers")
Next intSub

End Sub

Private Sub btnAscending_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAscending.Click
' sorts the array values in ascending order, then
' displays the array values in ascending order

lstNumbers.Items.Clear()

Array.Sort(strIntegers)
For Each strInteger As String In strIntegers
lstNumbers.Items.Add(strInteger)
Next strInteger

End Sub

Private Sub btnDescending_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDescending.Click
' sorts the array values in decending order, then
' display the array values in descending order

lstNumbers.Items.Clear()

Array.Sort(strIntegers)
Array.Reverse(strIntegers)
For Each strInteger As String In strIntegers
lstNumbers.Items.Add(strInteger)
Next strInteger

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
```

This post has been edited by AdamSpeight2008: 02 March 2012 - 03:12 PM

Is This A Good Question/Topic? 0

## Replies To: Sorting Algorithms

### #2 sela007

• D.I.C Addict

Reputation: 138
• Posts: 841
• Joined: 21-December 11

## Re: Sorting Algorithms

Posted 03 March 2012 - 05:37 PM

As far as I understood, you must wrote your own algorithm for sorting. Both bubble and selection technique. First you must learn and understand sorting techniques. Here you can find explanations and pseudo code:Bubble sort,Selection sort

This post has been edited by sela007: 03 March 2012 - 05:41 PM

Was This Post Helpful? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }