Silverlightのカルチャデータはプラットフォーム依存
http://blogs.msdn.com/michkap/archive/2008/10/16/9001396.aspx
ArrayクラスのSortメソッドはCultureInfo.CurrentCultureプロパティに基づいた配列を並べ替えが行われます。Silverlightのカルチャデータはプラットフォーム依存となっているため、同じja-JPというカルチャであってもWindowsとMac OS Xでは並べ替えの結果が異なってくるため、注意が必要です。
XAML
<UserControl x:Class="SilverlightApp1.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="350" Height="460" FontSize="24" Loaded="UserControl_Loaded">
<StackPanel x:Name="LayoutRoot" Background="White">
<TextBlock x:Name="cultureNameTextBlock" HorizontalAlignment="Center"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Margin="5,0" Background="Gray" CornerRadius="5">
<StackPanel>
<TextBlock Text="オリジナル" HorizontalAlignment="Center" Foreground="White"/>
<ListBox x:Name="originalListBox" Margin="5"/>
</StackPanel>
</Border>
<Border Grid.Column="1" Margin="5,0" Background="Gray" CornerRadius="5">
<StackPanel>
<TextBlock Text="ソート後" HorizontalAlignment="Center" Foreground="White"/>
<ListBox x:Name="sortedListBox" Margin="5"/>
</StackPanel>
</Border>
</Grid>
</StackPanel>
</UserControl>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="350" Height="460" FontSize="24" Loaded="UserControl_Loaded">
<StackPanel x:Name="LayoutRoot" Background="White">
<TextBlock x:Name="cultureNameTextBlock" HorizontalAlignment="Center"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Margin="5,0" Background="Gray" CornerRadius="5">
<StackPanel>
<TextBlock Text="オリジナル" HorizontalAlignment="Center" Foreground="White"/>
<ListBox x:Name="originalListBox" Margin="5"/>
</StackPanel>
</Border>
<Border Grid.Column="1" Margin="5,0" Background="Gray" CornerRadius="5">
<StackPanel>
<TextBlock Text="ソート後" HorizontalAlignment="Center" Foreground="White"/>
<ListBox x:Name="sortedListBox" Margin="5"/>
</StackPanel>
</Border>
</Grid>
</StackPanel>
</UserControl>
Visual Basic
Imports System.Globalization
Imports System.Threading
Partial Public Class Page
Inherits UserControl
Public Sub New()
InitializeComponent()
End Sub
Private Sub UserControl_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
cultureNameTextBlock.Text = Thread.CurrentThread.CurrentCulture.CompareInfo.ToString()
Dim stringList As String() = {"たなか", "すずき", "さとう", "タナカ", "スズキ", "サトウ", "タナカ", "スズキ", "サトウ"}
originalListBox.ItemsSource = stringList
Array.Sort(stringList)
sortedListBox.ItemsSource = stringList
End Sub
End Class
Imports System.Threading
Partial Public Class Page
Inherits UserControl
Public Sub New()
InitializeComponent()
End Sub
Private Sub UserControl_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
cultureNameTextBlock.Text = Thread.CurrentThread.CurrentCulture.CompareInfo.ToString()
Dim stringList As String() = {"たなか", "すずき", "さとう", "タナカ", "スズキ", "サトウ", "タナカ", "スズキ", "サトウ"}
originalListBox.ItemsSource = stringList
Array.Sort(stringList)
sortedListBox.ItemsSource = stringList
End Sub
End Class
Windows
Mac OS X