This is my tiny example of a string sort function, Comments suggestions welcome.
vbnet Code:
Public Class Form1
Public Function SortString(ByVal Source As String) As String
'Convert string to char array.
Dim Chars() As Char = Source.ToCharArray()
'Sort the char array
Array.Sort(Chars)
'Return sorted string
Return New String(Chars)
End Function
Private Sub cmdSort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSort.Click
MessageBox.Show(SortString("hfaebgcid"), "String Sort-Demo", MessageBoxButtons.OK, MessageBoxIcon.Information)
MessageBox.Show(SortString("9351274680"), "Number Sort-Demo", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
End Class