Sort a string with your own IComparer definition
Imports System.Collections
Imports System.Collections.Generic
Imports System.Globalization
Module Example
Public Sub Main()
Dim strings() As String = { "a","B","c","D" }
Dim stringSort(strings.Length - 1) As String
strings.CopyTo(stringSort, 0)
Array.Sort(stringSort, new SCompare())
End Sub
End Module
Friend Class SCompare : Implements IComparer(Of String)
Public Function Compare(x As String, y As String) As Integer _
Implements IComparer(Of String).Compare
Return CultureInfo.CurrentCulture.CompareInfo.Compare(x, y, CompareOptions.StringSort)
End Function
End Class
Related examples in the same category