# Submission c01c020a...

Challenge Integer sorting 0xabcdef0db461f2f... 2018-43-28 917090
``````/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
*/

pragma solidity 0.4.24;

contract Sort {

/**
* @dev Sorts a list of integers in ascending order.
*
* The input list may be of any length.
*
* @param input The list of integers to sort.
* @return The sorted list.
*/
function sort(uint[] input)
public
pure
returns(uint[]) {

if (input.length < 2) {
return input;
}
uint t = input.length - 1;
sortHelper(input, 0, t);
if (t < 3) {
return input;
}
quickSortAsc(input, 0, t, input[t / 2]);
return input;
}

function sortHelper(uint [] input, uint head, uint tail)
internal
pure
{
uint tmp = tail - head;
if (tmp == 1) {
}
} else {
tmp = (head + tail) / 2;
if (input[tmp] < input[tail]) {
} else {
(input[tmp], input[tail]) = (input[tail], input[tmp]);
} else {
}
}
} else {
if (input[tmp] < input[tail]) {
} else {
}
} else {
}
}
}
}

function quickSortAsc(uint[] input, uint head, uint tail, uint mval)
internal
pure
{
if (tail - head < 3) {
return;
}
uint t = tail;
while (h <= t) {
while (input[h] < mval) {
h++;
}
while (mval < input[t]) {
t--;
}
if (h <= t) {
(input[h], input[t]) = (input[t], input[h]);
h++;
if (t > 0) {
t--;
}
}
}