# Submission af4ec405...

Challenge Integer sorting 0x888888417655103... 2018-10-30 861797
``````pragma solidity 0.4.24;

contract Sort {

function sort(
uint[] input
) public pure returns(uint[]) {
if (input.length == 0) { return; }
choosePivot(input, 0, input.length-1);
quickSort(input, 0, int(input.length-1), input[(input.length-1)/2]);
return input;
}

function choosePivot(
uint[] input,
uint tail
) internal pure {
uint middle = (head + tail) / 2;
if (input[middle] < input[tail]) {
return;
}
(input[middle], input[tail]) = (input[tail], input[middle]);
return;
}
return;
}
if (input[middle] < input[tail]) {
return;
}
return;
}
return;
}

function insertSort(
uint[] input,
int tail
) private pure {
int j;
uint tmp;
for (uint i = uint(head)+1; i <= uint(tail); i++) {
tmp = input[i];
j = int(i - 1);
for (; j >= head; j--) {
if (tmp > input[uint(j)]) { break; }
input[uint(j)+1] = input[uint(j)];
}
input[uint(j)+1] = tmp;
}
}

function quickSort(
uint[] input,
int tail,
uint pivot
) private pure {
int t = tail;
while (input[uint(h)] < pivot) { h += 1; }
while (pivot < input[uint(t)]) { t -= 1; }
while (h <= t) {
(input[uint(h++)], input[uint(t--)]) = (input[uint(t)], input[uint(h)]);
while (input[uint(h)] < pivot) { h += 1; }
while (pivot < input[uint(t)]) { t -= 1; }
}
if (t - head > 8) {