Click or drag to resize
Accord.NET (logo)

SortPartitionT Method (T, Int32, Int32, FuncT, T, Int32, Boolean)

Reorders the elements in the range [left, right) in such a way that all elements for which the function compare returns true precede the elements for which compare returns false. Relative order of the elements is not preserved. This function should be equivalent to C++'s std::partition.

Namespace:  Accord
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0
public static int Partition<T>(
	this T[] items,
	int first,
	int last,
	Func<T, T, int> compare,
	bool asc = true
Request Example View Source


Type: T
The list to be reordered.
Type: SystemInt32
The beginning of the range to be reordered.
Type: SystemInt32
The end of the range to be reordered.
Type: SystemFuncT, T, Int32
Function to use in the comparison.
asc (Optional)
Type: SystemBoolean
Whether to sort in ascending or descending order.

Type Parameters


Return Value

Type: Int32
The index of the new pivot.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type . When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also