[corlib] Fix Array.Sort throwing when fewer keys than items are provided
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 9 Nov 2015 19:56:18 +0000 (20:56 +0100)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Tue, 10 Nov 2015 21:14:47 +0000 (22:14 +0100)
commitf736f9cda2c02c66d7a4f837dbced6bfe6a9e25d
tree2e2ad6140c1c83d3a2f21e70f71ec3ce059be6ab
parent29a02f2b12cee2e7b0cf10b3ae863b7ea1c588c6
[corlib] Fix Array.Sort throwing when fewer keys than items are provided

The `Sort<TKey, TValue> (TKey [] keys, TValue [] items, IComparer<TKey> comparer)` overload in Array throwed when keys.Length != items.Length.
However, on .NET you can pass in a keys array with fewer elements than in items and it'd sort the elements in items up to that point.

Fixed our implementation by only throwing when keys.Length > items.Length.

This was revealed by the coreclr/tests/src/CoreMangLib/cti/system/array/arraysort12.exe test.
I decided to port the test into our testsuite so we catch regressions earlier.
mcs/class/corlib/System/Array.cs
mcs/class/corlib/Test/System/ArrayTest.cs