Perform a string sort using the current culture with custom comparer
Imports System.Collections
Imports System.Collections.Generic
Imports System.Globalization
Module Example
Public Sub Main()
Dim strings() As String = {"this", "-is", "test",
ChrW(&HAD), "a", "A"}
Dim stringSort(strings.Length - 1) As String
strings.CopyTo(stringSort, 0)
Array.Sort(stringSort, New SCompare())
End Sub
End Module
' IComparer<String> implementation to perform string sort.
Friend Class SCompare : Implements IComparer(Of String)
Public Function Compare(ByVal x As String, ByVal 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