void sort(int *, unsigned); void sort (int * array, unsigned arrayLength) { if (arrayLength < 2) return; int * first = array; int * last = array + (arrayLength - 1); int * current; int temp = 1; for (current = first; temp && (current < last); current ++) if (*current < current[1]) temp = 0; if (temp) return; if (arrayLength == 2) { temp = *first; *first = *last; *last = temp; return; } current = last; while (first != last) { if (*first < *last) { temp = *first; *first = *last; *last = temp; current = (current == first) ? last : first; } if (current == last) first ++; else last --; } sort(array, current - array); sort(current + 1, arrayLength - 1 - (current - array)); }