NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Array.Sort (Array, Array, Int32, Int32, IComparer)

Sorts a section of a pair of one-dimensional Array objects- one containing the keys and the other containing the corresponding items- based on the keys in the first Array, using the specified IComparer interface.

[Visual Basic]
Overloads Public Shared Sub Sort( _
   ByVal keys As Array, _
   ByVal items As Array, _
   ByVal index As Integer, _
   ByVal length As Integer, _
   ByVal comparer As IComparer _
)
[C#]
public static void Sort(
   Array keys,
   Array items,
   int index,
   int length,
   IComparer comparer
);
[C++]
public: static void Sort(
   Array* keys,
   Array* items,
   int index,
   int length,
   IComparer* comparer
);
[JScript]
public static function Sort(
   keys : Array,
   items : Array,
   index : int,
   length : int,
   comparer : IComparer
);

Parameters

keys
The one-dimensional Array containing the keys to sort.
items
The one-dimensional Array containing the items that correspond to each of the keys in the keys Array.

-or-

a null reference (in Visual Basic Nothing) to sort only the keys Array.

index
The starting index of the range to sort.
length
The number of elements in the range to sort.
comparer
The IComparer implementation to use when comparing elements.

-or-

a null reference (Nothing) to use the IComparable implementation of each element.

Return Value

None.

Exceptions

Exception Type Condition
ArgumentNullException keys is a null reference (Nothing).
RankException keys is multidimensional.

-or-

items is not a null reference (Nothing) and is multidimensional.

ArgumentOutOfRangeException index is less than the lower bound of keys.

-or-

length is less than zero.

ArgumentException items is not a null reference (Nothing), and the lower bound of keys does not match the lower bound of items.

-or-

index and length do not denote a valid range in the keys Array.

-or-

items is not a null reference (Nothing), and index and length do not denote a valid range in the items Array.

InvalidCastException comparer is a null reference (Nothing), and one or more elements in the keys array does not implement the IComparable interface.

Remarks

Each key in the keys Array has a corresponding item in the items Array. When a key is repositioned during the sorting, the corresponding item in the items Array is similarly repositioned. Therefore, the items Array is sorted according to the arrangement of the corresponding keys in the keys Array.

If comparer is a null reference (Nothing), each key within the specified section of the keys Array must implement the IComparable interface to be capable of comparisons with every other key.

See Also

Array Class | Array Members | System Namespace | Array.Sort Overload List | IComparer | IComparable | BinarySearch