How to Bubblesort ILists in C# and VB.NET

To Bubblesort ILists in C# and VB.NET you can use the follwing snippet.

Sample C#

public static IList Sort(IList inputArray)
{
	var counter = inputArray.Count - 1;
	for (var i = 0; i < counter; i++)
	{

		for (var index = counter; index > i; index--)
		{
			if (((IComparable)inputArray[index - 1]).CompareTo(inputArray[index]) <= 0) continue;
			var temp = inputArray[index - 1];
			inputArray[index - 1] = inputArray[index];
			inputArray[index] = temp;
		}
	}
	return inputArray;
}

Sample VB.NET

Public Shared Function Sort(inputArray As IList) As IList
	Dim counter = inputArray.Count - 1
	For i As var = 0 To counter - 1

		For index As var = counter To i + 1 Step -1
			If DirectCast(inputArray(index - 1), IComparable).CompareTo(inputArray(index)) <= 0 Then
				Continue For
			End If
			Dim temp = inputArray(index - 1)
			inputArray(index - 1) = inputArray(index)
			inputArray(index) = temp
		Next
	Next
	Return inputArray
End Function

How to quicksort in PHP

To quicksort in PHP you can sue the following snippet.

Sample PHP

function Sort_Quicksort($input) 
{
    if(!count($input)) return $input;
    $data= $input[0];
    $small = $big = array();
    $length = count($input);
    for($i=1; $i < $length; $i++) {
        if($input[$i] <= $data) {
            $small [] = $input[$i];
        } else {
            $big[] = $input[$i];
        }
    }
    return array_merge(Sort_Quicksort($small), array($data), Sort_Quicksort($big));
}